Skip to content

Instantly share code, notes, and snippets.

@straight-shoota
Created November 3, 2014 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save straight-shoota/0eb19c3a3365759c75a8 to your computer and use it in GitHub Desktop.
Save straight-shoota/0eb19c3a3365759c75a8 to your computer and use it in GitHub Desktop.
Export Parish data from Bistum Augsburg (bistum-augsburg.de)
(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