You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
359 B

4 months ago
import requests, bs4
res = requests.get('https://www.nostarch.com')
res.raise_for_status()
noStarchSoup = bs4.BeautifulSoup(res.text)
print(type(noStarchSoup))
print(noStarchSoup.select('#main > p:nth-of-type(2)'))
print(noStarchSoup.select('p')[1])
print(noStarchSoup.select('p > a')[0].getText())
# https://beautiful-soup-4.readthedocs.io/en/latest/