Last active
December 16, 2021 15:01
-
-
Save marguslt/4ad715ae43475cd90031c29f9ff1f039 to your computer and use it in GitHub Desktop.
Scraping Movescount POIs into GPX
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
let gpx = `<?xml version="1.0" encoding="utf-8"?> | |
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" xmlns="http://www.topografix.com/GPX/1/1"> | |
`; | |
document.querySelectorAll("div.waypoint_item div.fl0.fs0").forEach(poi => { | |
let descr = poi.querySelector(".columns-header").innerText.trim(); | |
let [poi_match,poi_lat,poi_lon,poi_elev,poi_date,poi_time] = poi.querySelector(".columns-para").innerText.trim().match(/([\d.]+), ([\d.]+) ([\d.]+ m )?([\d.]+) ([\d:]+)/); | |
let [d_match,d,m,y] = poi_date.match(/(\d+)\.(\d+)\.(\d+)/) | |
let [t_match,hh,mm] = poi_time.match(/(\d+):(\d+)/); | |
let poi_datetime = new Date(y,m - 1,d,hh,mm); | |
let wpt = | |
` <wpt lat="${poi_lat}" lon="${poi_lon}"> | |
<time>${poi_datetime.toISOString()}</time> | |
<name>${descr}</name> | |
</wpt> | |
` | |
gpx += wpt; | |
}) | |
gpx += '</gpx>' | |
console.log(gpx) | |
copy(gpx) |
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
// list routes and gpx export links | |
// works only on a watch page ( https://www.movescount.com/gear/gear18.. ) | |
document.querySelectorAll("#waypointedRoute_items .columns").forEach(route => { | |
console.log(route.querySelector("div.fl0.fs0 > div.columns-header").innerText.trim()) | |
console.log(`https://www.movescount.com/Move/ExportRoute/${route.getAttribute("data-id")}?format=1`) | |
}) |
Author
marguslt
commented
Jan 22, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment