Last answered:

16 Mar 2023

Posted on:

17 Jan 2023

0

Resolved: I got the error while run the following code a['href'] and a['class']

import requests
from bs4 import BeautifulSoup
base_site="https://en.wikipedia.org/wiki/Music"
response=requests.get(base_site)
html=response.content
soup=BeautifulSoup(html,"html.parser")
a=soup.find_all("a",class_="mw-jump-link")
a['class']

1 answers ( 1 marked as helpful)
Posted on:

16 Mar 2023

0

Just for surety did you check a by printing it, may be soup didn't find the class you are going through so a just has an empty list 

so a['class'] might throws an error 

Hope this would be helpful to you

Mayank

Submit an answer