[Fixed]-Retrieve data from web app – POST request

1👍

You will have to change your validation function. In your first example, to validate whether there are results or not, you used the presence of the string ‘450’ at the beginning of the response to denote a false match. For the new site, there are more stuff being sent back to you, so it is just a matter of testing the differences.

The presence of the string ‘no se encuentra inscrita’ indicates a failed lookup. Sample code below. You can save this excerpt as a file and run from console before you make changes and integrate to your code.

from __future__ import print_function
import requests

def validate(nationality, id):
    baseurl = 'http://www.cne.gob.ve/web/registro_electoral/ce.php'
    query_params = '?nacionalidad=%s&cedula=%s' % (nationality, id)
    url = baseurl + query_params
    print(url + ': ', end='')
    if nationality == 'V' or nationality == 'E':
        s = requests.get(url).text
        if 'no se encuentra inscrita' not in s:
            return True
    return False

print(validate('V', '13253891'))
print(validate('V', '132538911'))
print(validate('V', 'jhiw300'))
print(validate('E', '13253891'))
print(validate('E', '132538911'))
print(validate('E', 'jhiw300'))
print(validate('X', '13253891'))
print(validate('X', '132538911'))
print(validate('X', 'jhiw300'))

Leave a comment