Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Created September 24, 2017 15:23
Show Gist options
  • Save sergiolucero/578553b3cfb84b714bfe7b8359f6d619 to your computer and use it in GitHub Desktop.
Save sergiolucero/578553b3cfb84b714bfe7b8359f6d619 to your computer and use it in GitHub Desktop.
scraping from the cops
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))
@fernandobillar
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment