Fictizia / Curso-JS-para-desarrolladores-web_ed10

FICTIZIA » Curso de JavaScript para desarrolladores web — 10ª Edición
https://fictizia.com/formacion/curso-javascript
GNU General Public License v3.0
17 stars 8 forks source link

Faros #18

Closed UlisesGascon closed 6 years ago

UlisesGascon commented 6 years ago

https://en.wikipedia.org/wiki/List_of_lighthouses_in_Spain

var faros = document.querySelectorAll("tbody")[2]
var faros = []

// loop 

farosJson = JSON.stringify(faros)
UlisesGascon commented 6 years ago
var faros = document.querySelectorAll("tbody:nth-child(2) > tr")

var lista_farera = [];
for (var i = 0; i < faros.length; i++) {
    var faroRaw = faros[i];
    var faro = {};
    faro.name = faroRaw.querySelector("a").innerText
    faro.wikipedia_link = faroRaw.querySelector("a").href
    faro.img =faroRaw.querySelector("img").src
    faro.link_mapa =faroRaw.querySelector("a:nth-child(2)").href
    faro.latitude = faroRaw.querySelector(".latitude").innerText;
    faro.longitude = faroRaw.querySelector(".latitude").innerText;
    // Meter más campos...
    // Generar la URL de Google Maps
    lista_farera.push(faro)
}

var json_PARA_casa = JSON.stringify(lista_farera)