Python BeautifulSoup UserWarning:没有明确指定解析器

时间:2016-05-13 13:47:00

标签: python-2.7 beautifulsoup

我正在使用Python27。我使用pip安装了BeautifulSoup4。

运行我的代码时出现以下错误:

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))

我的代码段是:

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

如果我只是运行以下行:

    for i in soup.body:
    print i

我如何解决错误? 谢谢,Riaz

0 个答案:

没有答案