Skip to content

Instantly share code, notes, and snippets.

@kvchen
Last active January 3, 2016 07:29
Show Gist options
  • Save kvchen/8429643 to your computer and use it in GitHub Desktop.
Save kvchen/8429643 to your computer and use it in GitHub Desktop.
scraper for facet.la
import requests
import shutil
from bs4 import BeautifulSoup
BASE_URL = "http://www.facet.la/wallpapers/"
r = requests.get(BASE_URL)
soup = BeautifulSoup(r.text)
# Loop through all images on the base thumbnail site
for thumb in soup.find_all("div", {"class" : "thumb-image"}):
# Follow each link and find the wallpaper url
img = requests.get(thumb.find("a")["href"])
s = BeautifulSoup(img.text)
wp_url = s.find("div", {"id" : "facet-image"}).find("img")["src"]
# Name our image
wp_name = wp_url.split('/')[-1]
print("Downloading {0}".format(wp_name))
# Download the image
response = requests.get(wp_url, stream=True)
with open(wp_name, 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment