proyectopetra / grx-PETRA

PETRA: Traffic Prediction and Monitoring
GNU General Public License v2.0
8 stars 1 forks source link

Traffic APIs study #3

Open fergunet opened 9 years ago

fergunet commented 9 years ago

I suggest @M42 and @fdavidcl but you can self-assign to other issues if you want: Some traffic API examples:

WAZE https://www.waze.com/es/about/dev Microsoft https://msdn.microsoft.com/en-us/library/hh441725.aspx Nokia HERE https://developer.here.com/rest-apis/documentation/traffic/topics/introduction.html EuropaPress http://www.europapress.es/trafico

Do you know others?

JJ commented 9 years ago

El escrapeo de europapress/trafico lo tenéis en el curso de Perl, pero @fdavidcl y @m42 ya estuvieron en la charla, así que supongo que se acordarán.

fergunet commented 9 years ago

Cool. By the way, we are going to switch issues to English to facilitate the judges work :)

We should translate our previous comments, also :)

fdavidcl commented 9 years ago

Alright. I've already investigated these APIs a bit:

Do you want me to upload the code somewhere in the repo?

fdavidcl commented 9 years ago

Apparently a request with parameters to Europa Press is of the type:

curl --data-urlencode "__VIEWSTATE=%2FwEPDwUKMjEyNjQ5ODQ4MGRkU2VbKJPokWLsSlLEjOkZUVJoWVM%3D&__VIEWSTATEGENERATOR=C0A6878A&ctl00%24ContenidoCentral%24ddlCCAA=&ctl00%24ContenidoCentral%24txtCarretera=&ctl00%24ContenidoCentral%24ddlNiveles=&ctl00%24ContenidoCentral%24ddlProvincia=&ctl00%24ContenidoCentral%24ddlIncidencias=Todas&ctl00%24ContenidoCentral%24btnBuscar=Buscar" -v http://www.europapress.es/trafico

But this doesn't return any data, nor a redirection. Any incorrect POST request (not providing the __VIEWSTATE and __VIEWSTATEGENERATOR) will return a HTML with general data from everywhere in Spain.

JJ commented 9 years ago

You're probably better off just scraping.

stringparser commented 9 years ago
curl http://www.dgt.es/incidencias.xml

ver abajo algo que parece una api https://datospublicos.jottit.com/tr%C3%A1fico_y_transporte

mroman42 commented 9 years ago

I have just added a script scraping the data in http://infocar.dgt.es/etraffic/. 78f9080b But it would be great to find a simpler way to get the data.

stringparser commented 9 years ago

I think I found something

curl http://www.dgt.es/incidencias.xml\?fecha\=20090101 > incidencias.xml
cat incidencias.xml | grep '2009'

with a date earlier than 2009 I can't found anything :)

stringparser commented 9 years ago

hahaha, I wrote in spanish :), fixed anyhow lets parse that xml thing

fdavidcl commented 9 years ago

No problem @stringparser, I'm adapting the R function to parse that XML instead and will upload it as soon as it works. Thanks for the links! :grin:

stringparser commented 9 years ago

great! :) I'll do it too just because we were all the morning parsing that pdfs ahahhaha

JJ commented 9 years ago

You are a bunch of f*cking geniuses!

stringparser commented 9 years ago

By the way the ?fecha= didn't work yesterday. Is weird, there is some 2009 dates there when you do that but it isn't really the history file from 2009.