import urllib
import urllib.request
from bs4 import BeautifulSoup
import os
from string import ascii_lowercase

def make_soup(url):
    thepage = urllib.request.urlopen(url)
    soupdata = BeautifulSoup(thepage, "html.parser")
    return soupdata

def take_image(n):
    i=1

    proxy = urllib.request.ProxyHandler({'http': '127.0.0.1'})
    opener = urllib.request.build_opener(proxy)
    urllib.request.install_opener(opener)
    urllib.request.urlopen(n)

    soup1 = make_soup(n)
    for img in soup1.select('a[href] img'):
        temp = img.find_parent('a', href=True)['href']

        try:
            if temp[:1] == "/":
                image = "https://,,,.hk" + temp
            else:
                image = temp
            print(image)

            filename = str(i)
            i = i + 1

            imagefile = open(filename + ".png", 'wb')
            imagefile.write(urllib.request.urlopen(image).read())
            imagefile.close()
        except:
            continue

with open('E:\Test.txt', 'r') as file:
    for line in file:
        n = line
        take_image(n)