Skip to content

Instantly share code, notes, and snippets.

@soncco
Created February 17, 2015 03:22
Show Gist options
  • Save soncco/c8e0018e22d30f693cc2 to your computer and use it in GitHub Desktop.
Save soncco/c8e0018e22d30f693cc2 to your computer and use it in GitHub Desktop.
RUC
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()
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