Created
August 21, 2018 19:21
-
-
Save kirussian911/61b2b692e2cd90c85ecefdf97ded6bdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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