Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 未安装Soupsieve软件包|自动化无聊的东西_Python_Beautifulsoup - Fatal编程技术网

Python 未安装Soupsieve软件包|自动化无聊的东西

Python 未安装Soupsieve软件包|自动化无聊的东西,python,beautifulsoup,Python,Beautifulsoup,我正在处理“自动化无聊的东西”中的网页抓取部分,在尝试使用BeautifulSoup UserWarning: The soupsieve package is not installed. CSS selectors cannot be used. 我已经运行了pip-install-beautifulsoup4和pip-install-soupsive。导致错误的行是: comicElem = soup.select('#comic img') 我环顾四周,没有找到解决办法。任何帮助都将

我正在处理“自动化无聊的东西”中的网页抓取部分,在尝试使用
BeautifulSoup

UserWarning: The soupsieve package is not installed. CSS selectors cannot be used.
我已经运行了
pip-install-beautifulsoup4
pip-install-soupsive
。导致错误的行是:

comicElem = soup.select('#comic img')
我环顾四周,没有找到解决办法。任何帮助都将不胜感激

import requests, os, bs4

url = 'http://xkcd.com'
os.makedirs('xkcd')
while not url.endswith('#'):
    print('Downloading page %s...' % url)
    res = requests.get(url)
    res.raise_for_status()

soup = bs4.BeautifulSoup(res.text, features="html.parser")
comicElem = soup.select('#comic img')
if comicElem == []:
    print('Could not find the comic image.')
else:
    comicUrl = 'http:' + comicElem[0].get('src')
#Download the image
    print('Downloading image %s...' % (comicUrl))
    res = requests.get(comicUrl)
    res.raise_for_status()

您能给出输出错误的代码吗?您安装了哪个版本的soupsieve?如果Soup Sieve无法导入,可能会发生这种情况。如果您尝试导入soupsive是否会出现错误?@Xilpex
comicElem=soup。选择(“#comic img”)
确定。谢谢…:D