Парсер vc.ru

Сегодня я вам покажу парсер статьи на vc.ru.

22

Спасибо огромное! А что так можно было?

Только в коде, есть ошибка. Или я что-то не так понял. Вот исправленная версия:
from bs4 import BeautifulSoup
import requests

url = 'https://vc.ru/u/1510590-python-idea/686866-oop-v-python'
response = requests.get(url)
print(response.status_code)

soup = BeautifulSoup(response.text, 'html.parser')
title = soup.find('h1', class_='content-title')
codes = soup.find_all('figure')
texts = soup.find_all('div', class_='l-island-a')
print(title.get_text(strip=True))
for text in texts:
print(text.get_text(strip=True))
for code in codes:
print(code.get_text(strip=True))

Ответить