Created
September 24, 2017 15:23
-
-
Save sergiolucero/578553b3cfb84b714bfe7b8359f6d619 to your computer and use it in GitHub Desktop.
scraping from the cops
This file contains hidden or 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
| from selenium import webdriver | |
| url='http://consultawebvehiculos.carabineros.cl/index.php' | |
| fd = webdriver.Firefox() | |
| plates = ['CZJB81','BDPW78'] | |
| sections = ['txtLetras','txtNumeros1','txtNumeros2'] | |
| def check_robo(patente): | |
| fd.get(url) # point to the starting page again | |
| patsplit = [patente[:2],patente[2:4], patente[4:]] | |
| for ix, sec in enumerate(sections): | |
| b = fd.find_element_by_id(sec) | |
| b.send_keys(patsplit[ix]) | |
| fd.find_element_by_name('crear').click() | |
| out = fd.find_element_by_id('u973-5').text | |
| return out | |
| for plate in plates: | |
| print(plate, check_robo(plate)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hola SERGIO. primero que todo agradecer el código, es un muy buen aporte. quisiera saber si es posible tomar este mismo código y hacer una consulta directa, desde un archivo csv.
saludos