gpt4 book ai didi

python - 如何使用Python报库?

转载 作者:行者123 更新时间:2023-11-28 16:32:17 25 4
gpt4 key购买 nike

我正在尝试制作网络解析器并保存它。我找到了 newspaper图书馆。我正在使用 Eclipse。但是我得不到好结果。请帮助我。

import newspaper

cnn_paper = newspaper.build('http://cnn.com')

for article in cnn_paper.articles:
print(article.url)

这是一条错误信息:

Traceback (most recent call last):
File "D:\workspace2\JesElaSearchSys\NespaperScraper_01.py", line 2, in <module>
import newspaper
File "C:\Python27\lib\site-packages\newspaper3k-0.1.5-py2.7.egg\newspaper\__init__.py", line 10, i
n <module>
from .article import Article, ArticleException
File "C:\Python27\lib\site-packages\newspaper3k-0.1.5-py2.7.egg\newspaper\article.py", line 12, in
<module>
from . import images
File "C:\Python27\lib\site-packages\newspaper3k-0.1.5-py2.7.egg\newspaper\images.py", line 15, in
<module>
import urllib.request
ImportError: No module named request

最佳答案

您的代码没有任何问题。您将需要安装或找到 newspaperrequest 库。您的开发机器上似乎缺少 newspaper/request 库。

$ pip install newspaper
$ pip install urllib3

上面的命令将帮助您安装它。

关于python - 如何使用Python报库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30645657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com