# When trying the Web scaping lesson I get the Error List Index out of range

**URL:** <https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469>\
**Category:** Python\
**Created:** [February 28, 2023, 7:29pm UTC](https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469 "2023-02-28T19:29:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![inquisitive](https://avatars.discourse-cdn.com/v4/letter/i/439d5e/32.png) [@inquisitive](https://forum.codewithmosh.com/u/inquisitive)\
**Post date:** [February 28, 2023, 7:29pm UTC](https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469/1 "2023-02-28T19:29:23Z")

</div>

I am practicing with the lesson of Web Scraping and I am applying the following program

```auto
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 am getting the error  
IndexError: list index out of range

I would appreciate any help as to why this error is happenning

---

<div class="post-metadata">

**Author:** ![Slash](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@Slash](https://forum.codewithmosh.com/u/Slash)\
**Post date:** [March 3, 2023, 2:43am UTC](https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469/2 "2023-03-03T02:43:33Z")

</div>

Greetings. Could be that the information that StackOverflow is returning is not an indexable type. Try:

print(response)

or

print(response.text)

After getting a response to see what the get response is returning

---

<div class="post-metadata">

**Author:** ![inquisitive](https://avatars.discourse-cdn.com/v4/letter/i/439d5e/32.png) [@inquisitive](https://forum.codewithmosh.com/u/inquisitive)\
**Post date:** [March 3, 2023, 8:54pm UTC](https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469/3 "2023-03-03T20:54:31Z")

</div>

Thank you. I will check and follow up with you.

---

<div class="post-metadata">

**Author:** ![lucidlear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/lucidlear/32/5477_2.png) [@lucidlear](https://forum.codewithmosh.com/u/lucidlear)\
**Post date:** [March 4, 2023, 6:27am UTC](https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469/4 "2023-03-04T06:27:02Z")

</div>

It looks like the page structure has changed on stackoverflow. Try:

questions = soup.select(“.s-post-summary.js-post-summary”)

instead of:

questions = soup.select(“.question-summary”)

and use “.s-link” instead if “.question-hyperlink” for the title

---

<div class="post-metadata">

**Author:** ![inquisitive](https://avatars.discourse-cdn.com/v4/letter/i/439d5e/32.png) [@inquisitive](https://forum.codewithmosh.com/u/inquisitive)\
**Post date:** [March 7, 2023, 5:40pm UTC](https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469/5 "2023-03-07T17:40:38Z")

</div>

Thank you so much. I will try it when i get well.

---

<div class="post-metadata">

**Author:** ![Ngai](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/ngai/32/5885_2.png) [@Ngai](https://forum.codewithmosh.com/u/Ngai)\
**Post date:** [March 21, 2023, 5:27pm UTC](https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469/6 "2023-03-21T17:27:59Z")

</div>

I am facing a similar issue.  
The following is my code.

url = “[Drawing Book Junior Series 7" x 10" (10pcs/Pkt) | Golden Tiger Stationery Store](https://m.goldentiger.store/product/5283)”

result = requests.get(url)

print(result.text)

doc = BeautifulSoup(result.text,“html.parser”)

print(doc.prettify())

prices = doc.find\_all(string= “Ks.”)

print(prices)

prices[0].parent

It shows this error.

"IndexError Traceback (most recent call last)  
 in   
1 prices = doc.find\_all(string= “Ks.”)  
2 print(prices)  
----\> 3 prices[0].parent

IndexError: list index out of range"

Is there anyway to resolve this?

---

<div class="post-metadata">

**Author:** ![CherylWashington](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/cherylwashington/32/5321_2.png) [@CherylWashington](https://forum.codewithmosh.com/u/CherylWashington)\
**Post date:** [April 25, 2025, 7:12am UTC](https://forum.codewithmosh.com/t/when-trying-the-web-scaping-lesson-i-get-the-error-list-index-out-of-range/18469/7 "2025-04-25T07:12:25Z")

</div>

I ran into the same issue and realized the structure of the page had changed. I fixed it by first printing out the HTML to see what was really inside the list. Also, if you’re [submitting a form with playwright](https://scrapingbytes.com/blog/playwright-submit-form), make sure the page has loaded completely before grabbing any elements—sometimes the form loads after the rest of the content, so your script might move too fast.
