-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffb_crawl.py
48 lines (33 loc) · 980 Bytes
/
ffb_crawl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# coding: UTF-8
import urllib, urllib2, sys;
from BeautifulSoup import BeautifulSoup;
import time;
OPENER = urllib2.build_opener();
OPENER.addheaders = [("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)")];
BASE_URL = "http://kroko.jp/ffbattle";
MY_DATA = {"id" : "tomo813", "pass" : "goyatomo813"};
fp = open("log.html", "w");
def save_res(res):
fp.write(res);
def hash_cat(dest, src):
for key in src:
dest[key] = src[key];
return (dest);
def doPost(post_data):
req = urllib2.Request(BASE_URL + "/monster.cgi", post_data);
res = urllib2.urlopen(req);
save_res(res.read());
return (res);
def goDungeon(dungeon_data):
data = hash_cat(dungeon_data, MY_DATA);
post_data = urllib.urlencode(data);
res = doPost(post_data);
return (res);
if __name__ == "__main__":
dungeon_data = {"mode" : "monster0", "chck" : "2"};
while (True):
print "go dungeon";
res = goDungeon(dungeon_data);
print "end";
time.sleep(10.0);
fp.close();