-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchive_rrrr.py
More file actions
58 lines (55 loc) · 1.89 KB
/
archive_rrrr.py
File metadata and controls
58 lines (55 loc) · 1.89 KB
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
49
50
51
52
53
54
55
56
57
58
'''
To archive http://rrrrthats5rs.com
'''
from requests import get
from os import chdir
from graphic_terminal import clearLine
from indentprinter import *
import re
def main():
chdir('d:/rrrr/')
print('getting the list of games...')
with indentPrinter:
response = get('http://www.rrrrthats5rs.com')
if response.status_code == 200:
print('Got response. ')
else:
print('Error', response.status_code)
return
with open('index.html', 'wb+') as f:
f.write(response.content)
games = [x.split('/"', 1)[0] for x in response.text.split('/games/')[1:]]
print('all games:')
with indentPrinter:
[print(x) for x in games]
oks = [getGame(x) for x in games].count(True)
print('All is done.', oks, '/', len(games), 'success.')
def getGame(game):
print('getting', game, '...')
with indentPrinter:
response = get('http://www.rrrrthats5rs.com/games/%s/' % game)
if response.status_code == 200:
print('Got response. ')
else:
print('Error', response.status_code)
return
with open('game_pages/%s.html' % game, 'wb+') as f:
f.write(response.content)
parts = response.text.split('embedSWF("')
if len(parts) != 2:
print('Error', 'cannot find swf address. splitted into', len(parts), 'parts.')
return
address = parts[1].split('"', 1)[0]
print('swf address:', address)
print('Getting swf...', end = '', flush = True)
response = get('http://www.rrrrthats5rs.com' + address)
clearLine()
if response.status_code == 200:
print('Got swf. ')
else:
print('Error', response.status_code)
return
with open('swfs/%s.swf' % game, 'wb+') as f:
f.write(response.content)
return True
main()