[英]newspaper3k - get articles from HTML instead of URL
我在Scrapy
解析方法中使用newspaper3k
。 我想提取链接,但我不想再次获取该网站。
是否可以使用这个:
newspaper.build(..)
使用普通html
这样我就可以调用.articles
比?
我找到了这个解决方案:
import httpx
from newspaper import Article
async def get_article(url):
with httpx.AsyncClient() as client:
response = await client.get(url)
article = Article(url)
article.set_html(response.text)
article.parse()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.