/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
python_webscraper.py
19 строк
574 B
Vardhaman
Rename python_webscraper to python_webscraper.py
10 авг 2022, 20:13
Не верифицирован
10 авг 2022, 20:13
137798c
Код
Авторство
О чём код?
import requests from bs4 import BeautifulSoup # Make a request on to your website page = requests.get("Paste your Website Domain here") soup = BeautifulSoup(page.content, 'html.parser') # Create all_h1_tags as empty list all_h1_tags = [] # Set all_h1_tags to all h1 tags of the soup for element in soup.select('h1'): all_h1_tags.append(element.text) # Create seventh_p_text and set it to 7th p element text of the page seventh_p_text = soup.select('p')[6].text print(all_h1_tags, seventh_p_text) # print all h1 elements and the text of the website on your console