Skip to content

Instantly share code, notes, and snippets.

/demo.py Secret

Created February 13, 2016 16:53
Show Gist options
  • Save anonymous/3a17a705163b622d83d6 to your computer and use it in GitHub Desktop.
Save anonymous/3a17a705163b622d83d6 to your computer and use it in GitHub Desktop.
import re
import urllib2
import time
max_page = 1
sleep = 1
dict_ = {}
for i in range(0,max_page+1):
time.sleep(sleep)
response = urllib2.urlopen('http://v2ex.com/go/afterdark?p='+str(max_page))
for link in re.findall('href="/t/.*?"',response.read()):
time.sleep(sleep)
response0 = urllib2.urlopen('http://v2ex.com'+link[6:-1]).read()
for p_url in re.findall('(http://ww[0-9]\.sinaimg\.cn/.*?/.*?\.(jpg|png|gif))',response0):
if p_url[0] not in dict_:
print p_url[0]
dict_[p_url[0]] = ''
for p_url in re.findall('(http://i\.imgur\.com/.*?\.(jpg|png|gif))',response0):
if p_url[0] not in dict_:
print p_url[0]
dict_[p_url[0]] = ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment