python - 这个 Python plus BeautifulSoup 脚本有什么问题?
问题描述
我正在使用 BeautifulSoup 学习网页抓取。我需要帮助解决此错误。到目前为止,这是我的代码:
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
my_url = 'https://www.newegg.com/Video-Cards-Video-Devices/Category/ID-38?
Tpk=graphics%20card'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
输出:
Traceback (most recent call last):
File "C:\Users\PC\Desktop\new.py", line 9, in <module>
page_soup = soup(page_html, "html.parser")
File "C:\Users\PC\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\bs4\__init__.py", line 153, in __init__
builder = builder_class()
File "C:\Users\PC\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\bs4\builder\_htmlparser.py", line 39, in __init__
return super(HTMLParserTreeBuilder, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'strict'
[Finished in 5.8s with exit code 1]
[cmd: ['C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python37-
32\\python.exe', '-u', 'C:\\Users\\PC\\Desktop\\new.py']]
[dir: C:\Users\PC\Desktop]
[path: C:\Program Files\Common
Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\C:\;C:\Users\PC\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\PC\AppData\Local\Programs\Python\Python37-32\;C:\Users\PC\DownAPK]
我将不胜感激有关修复此错误的任何帮助...谢谢
解决方案
sudo pip install requests --upgrade
推荐阅读
- mysql - 创建表,将某些列的类型定义为某个函数的返回类型
- python - 我正在实现“异或”功能,但它失败了
- java - 如何解决错误以及如何使用 oops 概念做得更好?
- javascript - 是否可以在 iFrame 中伪造国家/地区?
- html - CSS:“transform:translate”突然停止在chrome mobile中工作
- visual-studio - 运行时权限检查 Xamarin
- python-3.x - 简单的四舍五入小数位
- node.js - 本节有什么问题
- flutter - 颤振 setState 不会重新渲染我的孩子有状态小部件
- rust - RUST 特征扩展