运行出现了: File "E:/owncloud/python_test/img_get.py", line 15, in getbaiduimg data = BeautifulSoup(html,lxml) File "C:\Users\16649\Anaconda3\lib\site-packages\bs4_init_.py", line 149, in init if features is None or len(features) == 0: TypeError: object of type 'module' has no len()
源码: import lxml import requests from bs4 import BeautifulSoup
def getbaiduimg(URL): HEADERS = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36", "DNT":"1" } html = requests.get(URL,headers=HEADERS) print(html.text) shtml = html.text data = BeautifulSoup(shtml,lxml)
#tiebaurl = input('please input your baidu tieba url : ')
getbaiduimg('https://www.v2ex.com/')
怎么会出现这种情况呢,本人小白。。求大神帮忙解决下
1
tomczhen 2016-08-25 19:51:24 +08:00
你为什么不问问神奇海螺呢?
|
2
holajamc 2016-08-25 20:14:53 +08:00 1
额建议你用 md 写问题,我试了试直接复制你的代码没有问题,没有用 lxml ,使用的是 html.parser
|
3
lxy 2016-08-25 20:23:00 +08:00 1
|