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

i=1
soup = make_soup("https://2...content-available-to-author-only...h.hk/pr/res/1130518.html")
for img in soup.select('a[href] img'):
    temp = img.find_parent('a', href=True)['href']

    if temp[-1:] == "/":
        continue
    else:
        if temp[:1] == "/":
            image = "https://2...content-available-to-author-only...h.hk" + temp
        else:
            image = temp
        print(image)

        nametemp = img.get('alt')
        if len(nametemp) == 0:
            filename = str(i)
            i = i + 1
        else:
            filename = nametemp

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