17 lines
332 B
Python
17 lines
332 B
Python
# %pip install beautifulsoup4
|
|
|
|
from pprint import pprint
|
|
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
def scrape_h1():
|
|
url = 'http://example.com'
|
|
res = requests.get(url)
|
|
soup = BeautifulSoup(res.text, 'html.parser')
|
|
h1 = soup.find('h1').text
|
|
return h1
|
|
|
|
ph_dates = scrape_h1()
|
|
|
|
pprint(ph_dates) |