BeautifulSoup解析网页,出现错误:
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, 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 4 of the file C:/Users/excalibur/PycharmProjects/learn/getMyIP.py. To get rid of this warning, change code that looks like this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "lxml")
markup_type=markup_type))
发现原来的语句没有lxml这个参数的。下面是代码:
meizi_url.append(start_url)
r = requests.get(start_url)
soup = BeautifulSoup(r.text,"lxml")####加上lxml就可以了