Solutions for python3.x BeautifulSoup ([Your markup], "lxml") markup_type=markup_type))

Source: Internet
Author: User

1 Random.seed (Datetime.datetime.now ())2 defgetlinks (articleurl):3html = Urlopen ("http://en.wikipedia.org"+Articleurl)4BSODJ =BeautifulSoup (HTML)5     returnBsodj.find ("Div",{"ID":"bodycontent"}). FindAll ("a", Href=re.compile ("^ (/wiki/) ((?!:).) *$"))6Links = getlinks ("/wiki/kevin_bacon")7  whileLen (links) >0:8Newarticle = Links[random.randint (0,len (links)-1)].attrs["href"]9     Print(newarticle)TenLinks = getlinks (newarticle)

This is my source code, and then I report a warning.

D:\Anaconda3\lib\site-packages\bs4\__init__. Py:181:userwarning:no parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, butifYou run this code on another system,or inchA different virtual environment, it may use a different parser andbehave differently. The code that caused this warning isOn line the file D:/thronepython/python3 network data crawl/beautifulsoup crawler _ Start Crawl/beautifulsoup Wikipedia six-degree split _ build crawler. py from one page to another. To get rid of the This warning, the change code, the looks like This:beautifulsoup ([your markup]) to This:beautifulsoup ([Your Mar Kup],"lxml") Markup_type=markup_type))

Baidu found, in fact, this is not set the default parser caused by,

Set the parser to the prompt, or take the default parser and change the fourth line to:

    BSODJ = BeautifulSoup (HTML,"lxml")

Can.

Solutions for python3.x BeautifulSoup ([Your markup], "lxml") markup_type=markup_type))

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.