Created
November 3, 2014 18:43
-
-
Save straight-shoota/0eb19c3a3365759c75a8 to your computer and use it in GitHub Desktop.
Export Parish data from Bistum Augsburg (bistum-augsburg.de)
This file contains 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
(String.prototype.strip = -> @replace(/^\s+|\s+$/g, "")) unless typeof "".strip == "function" | |
data = [] | |
#document.querySelectorAll('.full_view_standard a.alphabet') | |
single_urls = ["http://www.bistum-augsburg.de/index.php/bistum/Pfarreien/Maria-Schnee-_Aach"] | |
for url in single_urls | |
get url, (dom) -> | |
list = dom.querySelector('#container_content').querySelectorAll('.liste_links, .liste_rechts') | |
console.log "loading #{url}" | |
item = {} | |
for elem, i in list by 2 | |
item[elem.innerText.strip().replace(/:$/, '')] = list[i + 1].innerText.strip() | |
console.log item | |
data.push item | |
get = (url, callback) -> | |
xmlhttp = new XMLHttpRequest() | |
xmlhttp.onload = -> | |
parser = new DOMParser() | |
dom = parser.parseFromString @response, "text/html" | |
callback(dom) | |
xmlhttp.open "GET", url | |
xmlhttp.send() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment