Lesson 2: Error downloading images (Invalid URL)

My download links from using the Javascript looks like this: https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcT4vcf9ev4ozewwikw6Qn8iJ-xFqj4j38kx1hX3Hg7SqhLW9uja When I run the download_images code I get the following error:

Is this a problem with Kaggle kernels?

I am facing the same problem with google colab

If you can, share the colab here. I will take a look in my free time. Also, please also post the link for downloading the image.
In these days, I generally just download image into a folder and upload it for training because we may have some issue in google image way. If you want do it in that way, I can download your image into a folder, train it, and write the code on code lab for you in my free time.

Thanks @JonathanSum for looking into my error.
I just got it working. The csv file containing the urls had blank lines which was giving rise to the errors since download_images function treated empty lines as urls. Removing the empty lines worked for me. :slightly_smiling_face:

How did you approach removing the empty lines? I did a pd.read_csv which automatically removes the blank lines and then converted the pandas dataframe back to csv using to_csv

I used a simple python code to read the csv file and create a new csv without the blank lines. Here’s the code I used:
with open('black.csv', 'r') as file1: with open('newblack', 'w') as file2: for line in file1: if not line.isspace(): file2.write(line)

I didn’t know about the read_csv and to_csv trick. That seems pretty neat too.