Skip to content

Instantly share code, notes, and snippets.

@sauravtom
Created May 14, 2017 06:10
Show Gist options
  • Save sauravtom/84acea1c081994895d3b644da2e30559 to your computer and use it in GitHub Desktop.
Save sauravtom/84acea1c081994895d3b644da2e30559 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
import webbrowser
# http://s.imgur.com/a/ksnRO/zip
def main():
arr = []
url = 'http://imgur.com/a/ksnRO/layout/blog'
html = requests.get(url).text;
soup = BeautifulSoup( html )
for node in soup.find_all('div',{'class' : 'post-image'}):
try:
image_url = node.img.get('src')
arr.append(image_url)
#webbrowser.open('http:'+image_url)
#break
except AttributeError:
print node
pass
print len(arr)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment