AllImgURL = []
def GetPageURL(root, Start, counts):
if Start == 1:
AllPage.append(“http://pic.netbian.com/index.html”)
for i in range(Start + 1, Start + counts):
newURL = root.replace(“%d”, str(i))
AllPage.append(newURL)
else:
for i in range(Start, Start + counts):
newURL = root.replace(“%d”, str(i))
AllPage.append(newURL)
def GetImgHTML(AllPage):
for PageURL in AllPage:
try:
res = requests.get(PageURL)
res.raise_for_status()
except HTTPError:
print(“HTTP Error!”)
except ConnectionError:
print(“Failed to connect!”)
with open(“C:/Users/86135/Desktop/PageFile.txt”, “w”, encoding=“ISO-8859-1”) as PageFile:
PageFile.write(res.text)
PageFile.close()
with open(“C:/Users/86135/Desktop/PageFile.txt”, “r”, encoding=“gbk”) as ReadFile:
str = ReadFile.read()