Download Images from list of urls

前端 未结 4 641
梦如初夏
梦如初夏 2021-02-15 23:45

I have a list of urls in a text file.i want the images to be downloaded to a particular folder ,how i can do it.is there any addons available in chrome or any other program to d

4条回答
  •  悲&欢浪女
    2021-02-16 00:08

    This needs to be made into a function with error handling but it repeatedly downloads images for image classification projects

        import requests
    
        urls = pd.read_csv('cat_urls.csv') #save the url list as a dataframe
    
        rows = []
    
        for index, i in urls.iterrows():
            rows.append(i[-1])
    
        counter = 0
    
        for i in rows:
        
    
        file_name = 'cat' + str(counter) + '.jpg'
        
            print(file_name)
            response = requests.get(i)
            file = open(file_name, "wb")
            file.write(response.content)
            file.close()
            counter += 1
    

提交回复
热议问题