FAQ: Web Scraping with Beautiful Soup - Object Types

This community-built FAQ covers the “Object Types” 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 Object Types

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!

1 Like

hi there, I was wondering if i can use BeautifulSoup to obtain js or css data in a web page?


Probably embedded JavaScript and CSS codes can be obtained by looking for <script> tags and <style> tags. However, perhaps those linked externally will need to be got separately (so ​​you might want to look at <link> tags as well).

import requests
from bs4 import BeautifulSoup

webpage_response = requests.get('https://example.com/')

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

# find all <script> tags
scripts = soup.find_all('script')

# find all <style> tags
styles = soup.find_all('style')

# find all <link> tags
links = soup.find_all('link')

# print <script> tags

# print <style> tags

# print <link> tags

I’m doing the Data Science track and I’m totally lost on what “< p >” and “< div >” represent in this exercise.

When should I use soup.p instead of soup.div for example. Would have been nice to get an introduction on this before actually working with it.


I couldn’t agree more. This is the poorest written module so far in the Data Science Career Path. You’re asking us to do things you haven’t even introduced and explained to us yet. And not just once, but for almost every step within the lesson.

Seems like maybe it’s a new module as there is very little in the discussions on Web Scraping with BeautifulSoup, but was it even vetted before being added to the path?

Par for the course, I suppose. This is not the first time Codecademy has made things more difficult by introducing a concept after we’ve already been asked to complete a previous exercise with it…

Why is the tag not called tag and its called div?