@Vlad242

Почему не выводит названия фильма в парсинге?

Почему в консоле не выводит названия фильмов? а пишет None
import requests
from bs4 import BeautifulSoup
def trade_spiders (max_page):
    page = 1
    while page <= max_page:
        url = 'http://new-baskino.club/page/' + str(page)
        source_code = requests.get(url)
        plain_text = source_code.content
        soup = BeautifulSoup(plain_text, 'html.parser')
        for link in soup.find_all('div', attrs={"class": "posttitle"}):
            href = link.find('a')['href']
            print(href)
            title = link.string
            print(title)
        page+=1

trade_spiders(1)


5c1e952dbb57d877096695.png
  • Вопрос задан
  • 134 просмотра
Решения вопроса 1
gordon_shamway
@gordon_shamway
import requests
from bs4 import BeautifulSoup
def trade_spiders (max_page):
    page = 1
    while page <= max_page:
        url = 'http://new-baskino.club/page/' + str(page)
        source_code = requests.get(url)
        plain_text = source_code.content
        soup = BeautifulSoup(plain_text, 'html.parser')
        for link in soup.find_all('div', attrs={"class": "posttitle"}):
            href = link.find('a')['href']
            print(href)
            title = link.find('a').text
            print(title)
        page+=1

trade_spiders(1)
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы