转义字符串无法识别

时间:2017-11-27 08:45:37

标签: python beautifulsoup request

我正在使用python,requests和BeautifulSoup构建一个抓取web的应用程序。

我将类变量声明为:

minikube ip

我使用class myClass(object): TAG = "\"span\",{\"data-automation\":\"jobListingDate\"}"

验证了此TAG

我得到print self.TAG的输出为print self.TAG,表明"span",{"data-automation":"jobListingDate"}与此字符串self.TAG相同

但是以下两行代码产生了不同的结果:

  • "span",{"data-automation":"jobListingDate"}
  • r = requests.get("someURL")
  • html = BeautifulSoup(r.content, "html.parser")
  • html.find(self.TAG) #this line does not find anything at all

我很困惑,html.find("span",{"data-automation":"jobListingDate"}) #this line does find what I am after与此字符串self.TAG的不同之处,我没有正确转义过任何内容吗?

0 个答案:

没有答案