Last active
April 25, 2021 01:58
-
-
Save melpomene/6213074 to your computer and use it in GitHub Desktop.
Script to download all your images from dailyview.com (gamla bilddagboken.se)
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
Python script to download all your dailyview.com images | |
Run with 'python download.py' | |
Depends on requests and Beautiful soup | |
""" | |
from requests import get | |
from BeautifulSoup import BeautifulSoup, SoupStrainer | |
from time import sleep | |
def download(): | |
url = #put url to latest image here i.e. "http://dayviews.com/username/11111137/" | |
while True: | |
r = get(url).content | |
soup = BeautifulSoup(r) | |
for meta in soup.findAll('meta', property="twitter:image"): | |
print "Downloading ", meta['content'] | |
print "Downloading image..." | |
f = open(meta['content'][-10:], 'wb') | |
r = get( meta['content']) | |
for chunk in r.iter_content(): | |
f.write(chunk) | |
# Save next image link | |
last_url = url | |
for link in soup.findAll('a', rel=u"fancyImgGrp"): | |
url = link["href"] | |
# If they are stil the same, exit | |
if last_url == url: | |
print "Done" | |
exit() | |
sleep(1) # be nice to server | |
if __name__ == '__main__': | |
download() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment