url = "https://news.163.com/world/"
headers = {"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.57"}
response = requests.get(url, headers=headers)
html = response.text
soup = BeautifulSoup(html, "lxml")
content_all = soup.find_all(class_="news_title")
for content in content_all:
print(content.string)
pycharm运行结果显示Process finished with exit code 0
求问哪里出了问题呀?
你打开网页都没有数据的,怎么爬
请先采纳!
print(content_all)看看
匹配错误!