-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
33 lines (30 loc) · 794 Bytes
/
script.py
File metadata and controls
33 lines (30 loc) · 794 Bytes
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
#!/usr/bin/python
import sys, urllib
from BeautifulSoup import BeautifulSoup as BS
args = sys.argv
sock = urllib.urlopen("http://codeforces.com/contest/" + args[-2] + "/problem/" + args[-1])
soup = BS(sock)
_in = soup.findAll('div', {'class': 'input'})
_out = soup.findAll('div', {'class':'output'})
cnt = 0
for i in _in:
ins = i.pre.contents
f = open(args[-2] + args[-1] + str(cnt) + ".in", 'w')
for line in ins:
try:
f.write(line.replace('<br />', '') + '\n')
except TypeError, e:
None
cnt = cnt + 1
f.close()
cnt = 0
for o in _out:
outs = o.pre.contents
f = open(args[-2] + args[-1] + str(cnt) + ".out", 'w')
for line in outs:
try:
f.write(line.replace('<br />', '') + '\n')
except TypeError, e:
None
cnt = cnt + 1
f.close()