简体   繁体   中英

collecting images from website in python 2.7

I'm not geting actually why is the syntax error here on line 17:

parsed[2] = image["src"]

then on line 18 :

outpath = os.path.join(out_folder, filename)

then 19 also:

urlretrieve(urlparse.urlunparse(parsed), outpath)

This :

filename = image["src".spilit("/")[-1]

Should be :

filename = image["src"].split("/")[-1]  ## spell corrected and square bracket added. 

you make some syntax error, at line 17 you have to close the bracket

filename = image["src".spilit("/")[-1]

should be

filename = image["src"].spilit("/")[-1]

at line 20 you should put colon(:) at end

if image["src"].lower().startswith("http")

should be

if image["src"].lower().startswith("http"):

at line 21 why you put colon at end of statement? (remove colon) at line 26, this is indentation error, you have to indent properly

at line 29, use single colon and close main keyword

if __name__ == '__main__':

i think you run your script like:

python filename.py

you should provide extra command line argument like:

python filename.py extraarg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM