Skip to content

Instantly share code, notes, and snippets.

@PeterDing
Last active March 13, 2019 05:45
Show Gist options
  • Save PeterDing/7056210 to your computer and use it in GitHub Desktop.
Save PeterDing/7056210 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import re, os
s = u'\x1b[1;%dm%s\x1b[0m' # terminual color template
r = re.compile(r'[^ -~\n]+')
a = []
print ' --> runing', s % (93, 'http://www.xunlei6.com/2.htm')
f = os.popen("curl -s http://www.xunlei6.com/2.htm | iconv -f gbk -t utf8 | html2text -ascii | grep -E '(迅雷会|白|企)' | sort -u").read()
t = [i.strip() for i in r.sub(' ', f).split('\n') if i != '']
t = [tuple(re.split(r' +', i)) for i in t]
a.extend(t)
########################################
r1 = re.compile(r'http://www.xunleihuiyuan.net/vip/\d+?.html')
f = os.popen("curl -s http://www.xunleihuiyuan.net/rss.xml").read()
urls = r1.findall(f)
urls = list(set(urls))
for i in urls:
print ' --> runing', s % (93, '%s' % i)
ff = os.popen("curl -s %s | grep 'post-body formattext'" % i).read()
ff = re.sub(r'<[^<>]+>', '\n', ff)
t = [i.strip() for i in r.sub(' ', ff).split('\n') if i != '']
t = [tuple(re.split(r' +', i)) for i in t]
a.extend(t)
#########################################
a = list(set(a))
a.sort()
out = '\n'.join([' '.join(i) for i in a if len(i) == 2])
with open(os.path.join(os.path.expanduser('~'), '.xunlei_vip_account'), 'w') as g:
g.write('## %d accounts\n' % len(a))
g.write('#'*25 + '\n\n')
g.write(out)
print s % (92, ' # find'), s % (91, '%d' % len(a)), s % (92, 'infos')
print s % (92, ' # over')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment