Пакет соусов не установлен |автоматизировать скучные вещи - PullRequest
0 голосов
/ 03 марта 2019

Я работаю через веб-раздел «Автоматизация скучного материала» и получаю следующую ошибку при попытке использовать 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()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...