此Python加BeautifulSoup脚本有什么问题?

时间:2019-02-27 21:34:12

标签: python 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]

感谢您为解决此错误提供的帮助...谢谢

1 个答案:

答案 0 :(得分:0)

sudo pip install requests --upgrade