【发布时间】:2019-10-14 20:31:02
【问题描述】:
我正在使用 lxml 和 requests 模块,只是试图从网站解析文章。我尝试使用 BeautifulSoup 中的 find_all 但仍然是空的
from lxml import html
import requests
page = requests.get('https://www.thehindu.com/news/national/karnataka/kumaraswamy-congress-leaders-meet-to-discuss-cabinet-reshuffle/article27283040.ece')
tree = html.fromstring(page.content)
article = tree.xpath('//div[@class="article"]/text()')
一旦我打印文章,我会得到一个 ['\n','\n','\n','\n','\n'] 的列表,而不是文章的正文。我到底哪里错了?
【问题讨论】:
标签: python html web-scraping tags