Created
February 11, 2019 15:16
-
-
Save luxu/c6c663746a537853f07c8bb1280646c2 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
from requests import get | |
from bs4 import BeautifulSoup as bs | |
from shutil import copyfileobj | |
import os | |
html = get('http://www.afterfest.com.br/mr-moo-4a-edicao/') | |
soup = bs(html.content, 'html.parser') | |
def download_file(name, url, pasta): | |
os.makedirs(pasta, exist_ok=True) # armazena as na pasta | |
xpto = get(url, stream=True) | |
with open(u'{}/{}'.format(pasta,name), 'wb') as f: | |
copyfileobj(xpto.raw, f) | |
images = [i.a['href'] for i in soup.findAll('div', class_="thumbnail-image")] | |
for image in images[2:10]: | |
_image = image.split('/') | |
name = image.split('/')[-1] | |
pasta = u'_'.join([_image[4],_image[5],_image[6]]) | |
print(name) | |
download_file(name, image, pasta) | |
print(len(images)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment