2 месяца назад
Парсинг сайтов на Python
bash pip install requests beautifulsoup4 selenium scrapy lxml python import requests from bs4 import BeautifulSoup import time # Базовый парсинг с заголовками headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' } try: response = requests.get('https://example.com', headers=headers, timeout=10) response.raise_for_status() # Проверка на ошибки soup = BeautifulSoup(response.text, 'html.parser') # Поиск элементов titles = soup.find_all('h1') links = soup.find_all('a', class_='some-class') text = soup.find('div', id='content')...