issue downloading image from web

0 andrew clarke · July 23, 2015
Hi i am having a few issue, downloading a image from the web in tutorial 22,it is posting back that line nine 
SyntaxError: invalid syntax,also i have had request unknown modual.

import random
import urllib.request

def download_web_image(url):
    name = random.randrange(1,1000)
    full_name= str(name) +".jpg"
    urllib.request.urlretrieve(url(url, full_name)

    download_web_image (“")

any help will be greatly appreciated

Post a Reply


Oldest  Newest  Rating
0 Gregory Ballantine · July 23, 2015
Just a couple things I noticed:

urllib.request.urlretrieve(url(url, full_name)

Looks like you have an extra "url(" in there, or you're missing a parenthesis at the end of the line.

download_web_image (?")

That "?" at the beginning of the url should be a double quote (")
0 andrew clarke · July 23, 2015
hi tanks for the info, i also had another issue, it would not let me import url lib but thats because it was set up as version 2 and not 3 which i have now changed and now it works fine.

thank you for taking time out to help.
0 Lotfi Ace · July 28, 2015
just add # noinspection PyUnresolvedReferences 
a line before you import urllib, and it should be fine.
  • 1



This section is all about snakes! Just kidding.

Bucky Roberts Administrator