Jun-06-2024, 03:19 AM
When I run this, it actually will create the results for the first URL but not for the rest of them.
I made some very minor fixes to the code with no change.
I made some very minor fixes to the code with no change.
from urllib.request import urlopen from pathlib import Path with open(r'D:\Desktop\sites.txt', 'r', encoding='UTF-8') as file: while line := file.readline(): myurl = line.rstrip() myfold = myurl[9:11] myfn = myurl[9:13] myfilen = myfn + '.txt' Path("D:/Desktop/" + myfold).mkdir(parents=True, exist_ok=True) with urlopen(myurl) as webpage: content = webpage.read().decode() with open("D:/Desktop/" + myfold + "/" + myfilen , "w" ) as output: output.write(content)