Created
February 17, 2015 03:22
-
-
Save soncco/c8e0018e22d30f693cc2 to your computer and use it in GitHub Desktop.
RUC
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
import urllib, urllib2, pytesseract, os | |
from PIL import Image | |
f = open('/tmp/captcha.jpg', 'wb') | |
f.write(urllib.urlopen('http://www.sunat.gob.pe/cl-ti-itmrconsruc/captcha?accion=image').read()) | |
f.close() | |
codigo = pytesseract.image_to_string(Image.open('/tmp/captcha.jpg')) | |
print codigo | |
os.remove('/tmp/captcha.jpg') | |
data = [('codigo', codigo), ('accion', 'consPorRuc'), ('nroRuc', '20549949232'),] | |
url = 'http://www.sunat.gob.pe/cl-ti-itmrconsruc/jcrS00Alias' | |
enc = urllib.urlencode(data) | |
r = urllib2.urlopen(url, enc) | |
r.read() |
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
import urllib, urllib2, pytesseract, os | |
codigo = 'VCRH' | |
print codigo | |
data = [('codigo', codigo), ('accion', 'consPorRuc'), ('nroRuc', '20549949232'),] | |
url = 'http://www.sunat.gob.pe/cl-ti-itmrconsruc/jcrS00Alias' | |
enc = urllib.urlencode(data) | |
r = urllib2.urlopen(url, enc) | |
r.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment