Python - 腳本中使用了bs4.BeautifulSoup方法,執行時提示如下警告


#問題現象:

腳本中使用了bs4.BeautifulSoup方法,執行時提示如下警告:

D:\Program Files\python3\pyworks\getProxy.py:15: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

 

The code that caused this warning is on line 15 of the file D:\Program Files\python3\pyworks\getProxy.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor.

 

  proxyList = bs4.BeautifulSoup(proxyHTML.read())

 

#解決方法:

使用時添加html.parser參數

proxyList = bs4.BeautifulSoup(proxyHTML.read(),"html.parser")


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM