【发布时间】:2019-04-07 14:14:21
【问题描述】:
嗨,我正在尝试编写一个抓取 URL 的程序,如果抓取的数据包含特定的字符串,我该如何使用美丽的汤来实现这一目标
import requests
from bs4 import BeautifulSoup
data = requests.get('https://www.google.com',verify=False)
soup= BeautifulSoup(data.string,'html.parser')
for inp in soup.find_all('input'):
if inp == "Google Search":
print ("found")
else:
print ("nothing")
【问题讨论】:
-
也许
if "Google Search" in inp:?
标签: python python-3.x beautifulsoup