How to get rid of BeautifulSoup user warning?
How to get rid of BeautifulSoup user warning?

When you get this kind of error while dealing with PyDictionary or other modules, you can simply solve it by doing some changes in your utils.py file. In simple, we are learning How to get rid of BeautifulSoup user warning?

Warning (from warnings module): File "C:\Users\Bishwas Bhandari\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyDictionary\utils.py", line 5 return BeautifulSoup(requests.get(url).text) 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 5 of the file C:\Users\Bishwas Bhandari\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyDictionary\utils.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor.

Step1: Open C:\Users\Bishwas Bhandari\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\PyDictionary

Step2: Edit utils.py

As your code was:

import requests
from bs4 import BeautifulSoup
def _get_soup_object(url):
return BeautifulSoup(requests.get(url).text)

Step3: Add , features="html.parser" in your code.

import requests
from bs4 import BeautifulSoup
def _get_soup_object(url):
return BeautifulSoup(requests.get(url).text, features="html.parser")

Done….. Happy Pythoning….

Last modified: October 11, 2019

Author

Comments

Write a Reply or Comment

Your email address will not be published.