There is a TXT file with links to sites with images, each starts with a new row. How best to walk on them to substitute every one of them in URLLIB, in order to keep pictures on PC.
Example TXT file:
// A / B / img.jpg //a/b/img1.jpg. ....
I will substitute a link here.
urllib.request.urlretrieve (src, "img" + str (i) + ".jpg")
To take the information that is in your .txt file, there is a command that goes out of the box,
Open () .
In your case, it should look something like this:
file = open ("yourfile.txt", "r") For Line in File: # Line is one line from a text document # i.e. Link to your image. You can make Print (Line) to verify urllib.request.urlretrieve (SRC, "img" + str (Line) + ".jpg")