jeudi 8 mai 2014

collectionner des images du site Web en python 2.7 - Stack Overflow


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


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

0 commentaires:

Enregistrer un commentaire