【问题标题】:html5lib Error while scraping and installation抓取和安装时出现html5lib错误
【发布时间】:2019-05-12 05:32:11
【问题描述】:

我一直在尝试从航班网站上抓取数据。 这是我写的代码:

todays_date = str(date.today())
arrival_filename = todays_date+"Arrival_Data_IGI.csv"
res = requests.get("https://m.newdelhiairport.in/live-flight- 
 information.aspx?FLMode=A&FLType=D")
soup = BeautifulSoup(res.content,'lxml')
table = soup.find_all('table',{'id':'fids_row'})
df = pd.read_html(str(table))
arrival = df[0]
arrival_filename = todays_date+"_Arrival_Data_IGI.csv"
arrival.to_csv(arrival_filename)
arrival.to_csv("Arrival_Data_IGI(daily).csv")

但是当我运行代码时出现错误。出现的错误:

当我尝试使用pip install html5lib 安装 html5lib 时,出现以下错误:

安装任何库或升级 pip 时出错。

“无法获取 URL https://pypi.org/simple/pip/: 确认 ssl 证书时出现问题: HTTPSConnectionPool(host='pypi.org', port=443): 使用 url: /simple/pip/ 超出最大重试次数(由SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:证书链中的自签名证书 (_ssl.c:1051)'))) - 跳过"

【问题讨论】:

  • 请输入错误,除了截图,更容易帮助...
  • 首先尝试升级pip:pip install --upgrade pip
  • 因为你使用 BeautifulSoup(res.content,'lxml')。你应该安装 lxml lib 来解析 html 文件..
  • 你试过python -m easy_install html5lib吗? Pip 有时在 Windows 上会出现问题,尤其是在使用代理网络时。
  • @MUNGAINJOROGE 您的解决方案有效。非常感谢

标签: python web-scraping


【解决方案1】:

您应该升级pip。这个解决方案(来自thisgithub 对话)可以解决问题:

python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip

【讨论】:

  • 1.您是否尝试重新安装pip? 2. 你确定你没有任何本地版本的 pip(例如,在主目录中)?
【解决方案2】:

如果您使用的是 Windows,在 64 位版本上安装软件包时有时可能会出现问题。

您可以从here 下载 64 位版本的库。

然后在下载文件的路径上打开命令提示符并键入

pip install "name of the package".whl

由于下载的文件是轮子文件。

或者您可以从 Anaconda-Navigator 下载所需的软件包。

【讨论】:

    猜你喜欢
    • 2017-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 2020-10-28
    • 2019-08-01
    • 2019-03-08
    相关资源
    最近更新 更多