Using Selectors in Beautiful Soup to Scrape Using Classes & IDs

Import and Export

Here we use a Beautiful Soup selector to get all the tags in a webpage with that uses the css class "links" and also the tag in the webpage with the css id "main_header".

 1|  import requests
 2|  from bs4 import BeautifulSoup
 4|  response = requests.get('')
 5|  parser = BeautifulSoup(response.content, 'html.parser')
 7|  links =".links")
 9|  main_header ="#main_header")
1 Upvote
Did you find this snippet useful?

Sign up to bookmark this in your snippet library