Python Forum

Full Version: I am scraping a web page but got an Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to apply a program for scaping a webpage but the program was not executed sussfully. I am getting the error:

Error:
IndexError: list index out of range
The program I am executing is as follows:

import requests
from bs4 import BeautifulSoup
response = requests.get("https://stackoverflow.com/questions")
soup = BeautifulSoup(response.text, "html.parser")
questions = soup.select(".question-summary")
#print(type(questions[0]))
print(questions[0].attrs)
I would appreciate any help or idea as to why this was happening
questions returns None, thus the error.
I cannot find '.question-summary' anywhere on that webpage.
@Larz60+
Hello
Thanks for the reply. I will check and follw back
The (.question-summary) is a CSS class taken from the questions page of the website. I got it by write clicking on the website page and inspect as in the picture below
[Image: M2TX5]