Get An Inner Tag Using Beautiful Soup

Python

Here we find the first "a" inner tag within the first h2 tag on a wikipedia webpage.

 1|   import requests
 2|  from bs4 import BeautifulSoup
 3|  
 4|  response = requests.get('https://en.wikipedia.org/wiki/FTSE_100_Index')
 5|  parser = BeautifulSoup(response.content, 'html.parser')
 6|  
 7|  h2 = parser.find_all('h2')
 8|  
 9|  h2[0].find_all('a')[0]
Did you find this snippet useful?

Sign up for free to to add this to your code library