【发布时间】:2019-11-29 01:07:12
【问题描述】:
我正在尝试从网站获取文本,但找不到解决方法。需要怎么写?
link="https://www.ynet.co.il/articles/0,7340,L-5553905,00.html"
response = requests.get(link)
soup = BeautifulSoup(response.text,'html.parser')
info = soup.find('div', attrs={'class':'text14'})
name = info.text.strip()
print(name)
我每次都没有得到任何东西
【问题讨论】:
-
您的屏幕截图显示了 DOM,而 beautifulsoup 在源上运行。它们可以不同。
-
你试过这个
response = requests.get(link).text吗? -
@Amir 它给出了相同的结果
标签: python python-3.x web-scraping python-requests