Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue with my first Python test.
#1
I apologise for asking silly questions. I should think I will look at this in a couple of months and laugh at myself.

So here it goes: I've started to read a couple of posts here, and I just wanted to run my own scraper... Just to get a feeling of acheivement.. (even if it's not my script, haha).

Issue... :

from bs4 import BeautifulSoup

# Simulate a web page
html = '''\
<body>
  <div id='images'>
    <a href='image1.html'>Name: My image 1 <br /><img src='image1_thumb.jpg' /></a>
    <a href='image2.html'>Name: My image 2 <br /><img src='image2_thumb.jpg' /></a>
    <a href='image3.html'>Name: My image 3 <br /><img src='image3_thumb.jpg' /></a>
  </div>
</body>
'''
soup = BeautifulSoup(html, 'html.parser')
print([link.get('href') for link in soup.find_all('a')])
I got this code from a tutorial here. When I try to run this script, it says:

"from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'

Process finished with exit code 1"

How do I fix this?

Also, what would the code be to search an actual website be, say... Amazon?

Thanks in advance
Reply
#2
Have you install Beautiful soup yet? If not, type 'pip install bs4" on the command prompt.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python - Scrapy Ebay Test Baggelhsk95 4 4,320 Oct-16-2018, 12:37 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020