FAQ: Web Scraping with Beautiful Soup - Reading Text

This community-built FAQ covers the “Reading Text” exercise from the lesson “Web Scraping with Beautiful Soup”.

Paths and Courses
This exercise can be found in the following Codecademy content:

FAQs on the exercise Reading Text

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I want to ask, what’s wrong in my variant of solve:

import requests
from bs4 import BeautifulSoup

prefix = "https://s3.amazonaws.com/codecademy-content/courses/beautifulsoup/"
webpage_response = requests.get('https://s3.amazonaws.com/codecademy-content/courses/beautifulsoup/shellter.html')

webpage = webpage_response.content
soup = BeautifulSoup(webpage, "html.parser")

turtle_links = soup.find_all("a")
links = []
# go through all of the a tags and get the links associated with them:
for a in turtle_links:
    links.append(prefix + a["href"])

# Define turtle_data:
turtle_data = {}

# follow each link:
for link in links:
    webpage = requests.get(link)
    turtle = BeautifulSoup(webpage.content, "html.parser")
    turtle_name = turtle.select(".name")[0].get_text()
    turtle_data[turtle_name] = turtle.find("ul").get_text("|").split('|')

It’s give the same result as a variant from site

{'Aesop': ['\n', 'AGE: 7 Years Old', '\n', 'WEIGHT: 6 lbs', '\n', 'SEX: Female', '\n', 'BREED: African Aquatic Sideneck Turtle', '\n', 'SOURCE: found in Lake Erie', '\n'], 'Caesar': ['\n', 'AGE: 2 Years Old', '\n', 'WEIGHT: 4 lbs', '\n', 'SEX: Male', '\n', 'BREED: Greek Tortoise', '\n', 'SOURCE: hatched in house', '\n'], 'Sulla': ['\n', 'AGE: 1 Year Old', '\n', 'WEIGHT: 1 lb', '\n', 'SEX: Male', '\n', 'BREED: African Aquatic Sideneck Turtle', '\n', 'SOURCE: found in Lake Erie', '\n'], 'Spyro': ['\n', 'AGE: 6 Years Old', '\n', 'WEIGHT: 3 lbs', '\n', 'SEX: Female', '\n', 'BREED: Greek Tortoise', '\n', 'SOURCE: hatched in house', '\n'], 'Zelda': ['\n', 'AGE: 3 Years Old', '\n', 'WEIGHT: 2 lbs', '\n', 'SEX: Female', '\n', 'BREED: Eastern Box Turtle', '\n', 'SOURCE: surrendered by owner', '\n'], 'Bandicoot': ['\n', 'AGE: 2 Years Old', '\n', 'WEIGHT: 2 lbs', '\n', 'SEX: Male', '\n', 'BREED: African Aquatic Sideneck Turtle', '\n', 'SOURCE: hatched in house', '\n'], 'Hal': ['\n', 'AGE: 1 Year Old', '\n', 'WEIGHT: 1.5 lbs', '\n', 'SEX: Female', '\n', 'BREED: Eastern Box Turtle', '\n', 'SOURCE: surrendered by owner', '\n'], 'Mock': ['\n', 'AGE: 10 Years Old', '\n', 'WEIGHT: 10 lbs', '\n', 'SEX: Male', '\n', 'BREED: Greek Tortoise', '\n', 'SOURCE: surrendered by owner', '\n'], 'Sparrow': ['\n', 'AGE: 1.5 Years Old', '\n', 'WEIGHT: 4.5 lbs', '\n', 'SEX: Female', '\n', 'BREED: African Aquatic Sideneck Turtle', '\n', 'SOURCE: found in Lake Erie', '\n']}
1 Like

Is there something wrong when the site check codes? I copied the solution to the reset excersise, I still could not pass question 2.

3 Likes

Same here. Am I missing something ? I’ve also tried turtle.ul and turtle.find_all(“ul”)

2 Likes

Have the same like a previous guys.