Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- # Задаем данные для авторизации на сайте
- login_url = 'https://example.com/login'
- username = 'your_username'
- password = 'your_password'
- # Создаем сессию для отправки запросов на сайт
- session = requests.Session()
- # Отправляем POST-запрос на страницу авторизации для получения cookie-файлов и сессии
- login_data = {'username': username, 'password': password}
- session.post(login_url, data=login_data)
- # Отправляем GET-запрос на страницу с темами после авторизации
- themes_url = 'https://example.com/themes'
- response = session.get(themes_url)
- # Используем библиотеку BeautifulSoup для парсинга HTML-страницы
- soup = BeautifulSoup(response.text, 'html.parser')
- # Находим все элементы с классом "theme" на странице
- themes = soup.find_all('div', class_='theme')
- # Проходим по каждому элементу и выводим название темы и ее версию
- for theme in themes:
- name = theme.find('h2', class_='title').text
- version = theme.find('span', class_='version').text
- print(name, version)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement