Я работаю через веб-раздел «Автоматизация скучного материала» и получаю следующую ошибку при попытке использовать BeautifulSoup
UserWarning: The soupsieve package is not installed. CSS selectors cannot be used.
Я запустил pip install beautifulsoup4
и pip install soupsieve
,Строка, которая вызывает ошибку:
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()