Created
April 18, 2013 02:31
-
-
Save tomonari-masada/5409569 to your computer and use it in GitHub Desktop.
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/python | |
# -*- coding: utf-8 -*- | |
import os | |
import time | |
import random | |
mail_str = '[email protected]' | |
password_str = 'your_password' | |
match_str = '<tr class="tr_bg1">' | |
urank_file = 'urank.html' | |
wget_login ="wget -O temp.html --debug --cookies=on --no-check-certificate --ca-directory=/etc/ssl/certs --save-cookies=cookies.txt --keep-session-cookies --post-data='mail=%s&password=%s' http://book.akahoshitakuya.com/login" % (mail_str, password_str) | |
wget_urank = 'wget -O %s --keep-session-cookies --no-check-certificate --load-cookies cookies.txt "http://book.akahoshitakuya.com/urank&s=f"' % urank_file | |
if not os.path.exists(urank_file): | |
os.system(wget_login) | |
time.sleep(random.randint(5,15)) | |
os.system(wget_urank) | |
fp = open(urank_file, 'r') | |
for line in fp: | |
line = line.strip() | |
if line.find(match_str) == 0: | |
break | |
lines = [] | |
while True: | |
line = line[len(match_str):] | |
pos = line.find(match_str) | |
lines.append(line[:pos]) | |
if pos == -1: | |
break | |
line = line[pos:-1] | |
users = [] | |
for line in lines: | |
fields = line.split('"') | |
for field in fields: | |
if field.find('/u/') == 0: | |
users.append(field) | |
for user in users: | |
print "http://book.akahoshitakuya.com" + user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment