【求助】爬虫脚本总提示错误Traceback (most recent call last)

forarrow 2018-04-04 04:52:12
# coding=utf-8
import requests
from bs4 import BeautifulSoup

# 获取html文档
def get_html(url) -> object:
"""get the content of the url"""
response = requests.get(url)
response.encoding = 'utf-8'
return response.text

# 获取笑话
def get_certain_joke(html):
"""get the joke of the html"""
soup = BeautifulSoup(html, 'lxml')
joke_content = soup.select('div.content')[0].get_text()
return joke_content
url_joke = "https://www.qiushibaike.com"
html = get_html(url_joke)
joke_content = get_certain_joke(html)
print(joke_content)

错误提示:
Traceback (most recent call last):
File "C:/Users/cdyoue/PycharmProjects/untitled/JokePaTest.py", line 21, in <module>
joke_content = get_certain_joke(html)
File "C:/Users/cdyoue/PycharmProjects/untitled/JokePaTest.py", line 15, in get_certain_joke
soup = BeautifulSoup(html, 'lxml')
File "C:\Users\cdyoue\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\__init__.py", line 165, in __init__
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

Process finished with exit code 1
...全文
17547 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
littlefishinger 2019-10-08
  • 打赏
  • 举报
回复
WebDriverException Traceback (most recent call last) <ipython-input-8-933ea661e5f4> in <module> ----> 1 driver.find_element_by_id('J-search-input').send_keys('小笼包') #分析网页元素,寻找搜索框代码,向搜索框输入小笼包三个字 D:\360Downloads\anaconda\lib\site-packages\selenium\webdriver\remote\webelement.py in send_keys(self, *value) 477 self._execute(Command.SEND_KEYS_TO_ELEMENT, 478 {'text': "".join(keys_to_typing(value)), --> 479 'value': keys_to_typing(value)}) 480 481 # RenderedWebElement Items D:\360Downloads\anaconda\lib\site-packages\selenium\webdriver\remote\webelement.py in _execute(self, command, params) 631 params = {} 632 params['id'] = self._id --> 633 return self._parent.execute(command, params) 634 635 def find_element(self, by=By.ID, value=None): D:\360Downloads\anaconda\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params) 319 response = self.command_executor.execute(driver_command, params) 320 if response: --> 321 self.error_handler.check_response(response) 322 response['value'] = self._unwrap_value( 323 response.get('value', None)) D:\360Downloads\anaconda\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response) 240 alert_text = value['alert'].get('text') 241 raise exception_class(message, screen, stacktrace, alert_text) --> 242 raise exception_class(message, screen, stacktrace) 243 244 def _value_or_default(self, obj, key, default): WebDriverException: Message: unknown error: call function result missing 'value' (Session info: chrome=77.0.3865.90) (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64) 有人知道这是什么意思吗
forarrow 2018-04-08
  • 打赏
  • 举报
回复
引用 1 楼 oyljerry 的回复:
先pip install lxml安装一下
对喽~
oyljerry 2018-04-04
  • 打赏
  • 举报
回复
先pip install lxml安装一下

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧