coding utf- usr bin python import urllib import urllib2 import cookiel

 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
# -*- coding: utf- 8 -*
#!/usr/bin/python
import urllib
import urllib2
import cookielib
url1 = 'https://service.nalog.ru/debt/req.do'
url2 = 'https://service.nalog.ru/debt/captcha.do'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
request_main = urllib2.Request(url1)
content = opener.open(request_main).read()
request_captcha = urllib2.Request(url2)
captcha = opener.open(request_captcha).read()
f = open('/mnt/storage/share/media/captcha.gif', 'wb')
f.write(captcha)
f.close()
print 'enter captcha'
cap = raw_input()
data = 'inn=665899483364&fam=%D0%91%D0%B5%D1%80%D0%B5%D0%B6%D0%BD%D0%BE%D0%B2%D0%B0&nam=%D0%95%D0%BB%D0%B5%D0%BD%D0%B0&otch=&cap='+cap;
request_req_edit = urllib2.Request('https://service.nalog.ru/debt/req-edit.do', data)
req = opener.open(request_req_edit).read()
print req
data = urllib.urlencode({'token': req[1:-1]})
print data
request_debts = urllib2.Request('https://service.nalog.ru/debt/debts.do', data)
req = opener.open(request_debts).read()
print req