Python Forum

Full Version: Issue with my first Python test.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Have you install Beautiful soup yet? If not, type 'pip install bs4" on the command prompt.