具有以下为键盘检查某个网页的功能
def checkString():
url_a = 'https://launchstudio.bluetooth.com/ListingDetails/50756'
r_a = requests.get(url_a)
soup_a = BeautifulSoup(r_a.text)
for blem in soup_a(text=re.compile(r'RFCOMM')):
return True
return False
已经验证了我的soup\u a与url的视图源是相同的,但是我的搜索似乎只会返回包含在head标签中的结果,并且很难找出原因。有什么建议吗?你知道吗
Python版本2.7.5
您需要将
lxml
传递给BeautifulSoup
类。此外,如果找到匹配项,return True
将跳出for循环。因此,如果在head标签中确实找到了RFCOMM
,则循环将退出,不再注册匹配项。最好使用列表理解并确定是否找到匹配项:输出:
相关问题 更多 >
编程相关推荐