【发布时间】:2020-07-08 01:20:27
【问题描述】:
我试图完成的是一个简单的python网络抓取脚本,用于谷歌趋势并在抓取课程时遇到问题
from bs4 import BeautifulSoup
import requests
results = requests.get("https://trends.google.com/trends/trendingsearches/daily?geo=US")
soup = BeautifulSoup(results.text, 'lxml')
keyword_list = soup.find_all('.details-top')
for keyword in keyword_list:
print(keyword)
当打印 tag 我收到并清空类但是当我打印汤时我收到整个 HTML 文档。我的目标是打印出搜索页面https://trends.google.com/trends/trendingsearches/daily?geo=AU的每个“关键字”的文本
这有一个结果列表:
1. covid-19
2.Woolworths jobs
如果您使用谷歌开发者选项,请选择检查并将鼠标悬停在标题上,您将看到 div.details-top。
如何打印每个标题的文本
【问题讨论】:
标签: python-2.7 web-scraping beautifulsoup