BeautifulSoup Issue


#1

I am trying to use BS4 on C9, but I am having an issue when trying to run the following script. I have it running as expected on my PC, same code, but I get the error code below as well. Any thoughts?

import requests, urllib, urllib3
from bs4 import BeautifulSoup

url = input("Url: ")
if url[-1] != ‘/’:
url += ‘/’

r = requests.get(url)
soup = BeautifulSoup(r.text, ‘html.parser’)

picnum = 1
for xx in soup.findAll(‘img’):
try:
print("\n\nDownloading " + (url + xx[‘src’]))
urllib3.Request.urlretrieve(url + xx[‘src’], str(picnum) + “.jpg”)
picnum += 1
except:
print(url + xx[‘src’] + " didn’t download.")

HERE IS THE ERROR MESSAGE I RECEIVE:

Traceback (most recent call last):
File “/home/ubuntu/workspace/Python/Url/BS/bs.1.py”, line 2, in
from bs4 import BeautifulSoup
File “/usr/local/lib/python2.7/dist-packages/bs4/init.py”, line 53
’You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.’<>‘You need to convert the code, either by installing it (python setup.py install) or by running 2to3 (2to3 -w bs4).’
^
SyntaxError: invalid syntax