0

I am using Python27. I installed BeautifulSoup4 using pip.

I am getting the following error when i run my code:

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.

To get rid of this warning, change this:

 BeautifulSoup([your markup])

to this:

 BeautifulSoup([your markup], "html.parser")

  markup_type=markup_type))

My code snippet is:

from bs4 import BeautifulSoup

def extract_pass_summary_from_selenium_report():
    html_report = open(r"C:\test_runners\selenium_regression_test\ClearCore - Regression Test\TestReport\SeleniumTestReport.html",'r').read()
    soup = BeautifulSoup(html_report)

    #for i in soup.body:
    #    print i

    for i in soup.findAll('p', align="center"):
        print i

If i just run the following line it works:

    for i in soup.body:
    print i

How can i get around the error? Thanks, Riaz

Riaz Ladhani
  • 3,946
  • 15
  • 70
  • 127
  • 1
    I have changed soup = BeautifulSoup(html_report) to soup = BeautifulSoup(html_report, "html.parser") – Riaz Ladhani May 13 '16 at 13:50
  • And did that make the error go away? – wpercy May 13 '16 at 14:24
  • @RiazLadhani What is it that you referenced as ***error*** in *"How can i get around the **error**?"*? I strongly suspect it isn't the `UserWarning` since you have shown a way to get rid of it, and it is 'just' warning anyway (not an error). – har07 May 13 '16 at 15:03
  • @wilbur yes that made the error go away. – Riaz Ladhani May 13 '16 at 16:06

0 Answers0