Skip to content

Instantly share code, notes, and snippets.

@kirussian911
Created August 21, 2018 19:21
Show Gist options
  • Save kirussian911/61b2b692e2cd90c85ecefdf97ded6bdf to your computer and use it in GitHub Desktop.
Save kirussian911/61b2b692e2cd90c85ecefdf97ded6bdf to your computer and use it in GitHub Desktop.
import urllib.request
def load_source(website):
site = urllib.request.urlopen(website) # получаем код сайта
read_site = site.read() # читаем его
return read_site # возвращаем результат
def parse_img(source):
links = []
t = str(source).replace('550', ' ').replace('375', ' ').split('<img width=" " height=" " src="')
for i in t:
r = str(i).split('""')
links.append(r[0])
return links
def download(links):
name = 1
for i in links:
try:
v = urllib.request.urlopen(i)
print(v)
f = open(str(name) + '.jpg', 'wb')
f.write(v.read())
f.close()
name += 1
except:
pass
def main():
input('start:')
source = load_source('https://aliholic.com/shop/page/3')
links = parse_img(source)
download(links)
print('Thx')
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment