Created
September 5, 2019 18:33
-
-
Save mattborn/3eb7695e4fea0cf2709a3d406ef0146a to your computer and use it in GitHub Desktop.
Scrape sportstats
This file contains hidden or 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
// npm init -y && npm install node-fetch --save | |
const fetch = require('node-fetch') | |
const fs = require('fs') | |
for (let i = 0; i < 5; i++) { | |
fetch('https://www.sportstats.us/display-results.xhtml?raceid=105569', { | |
"credentials": "include", | |
"headers": { | |
"accept": "application/xml, text/xml, */*; q=0.01", | |
"accept-language": "en-US,en;q=0.9", | |
"content-type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"faces-request": "partial/ajax", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-site": "same-origin", | |
"x-requested-with": "XMLHttpRequest" | |
}, | |
"referrer": "https://www.sportstats.us/display-results.xhtml?raceid=105569", | |
"referrerPolicy": "no-referrer-when-downgrade", | |
"body": "javax.faces.partial.ajax=true&javax.faces.source=mainForm%3Aj_idt363%3A"+ i +"%3Aj_idt365&javax.faces.partial.execute=%40all&javax.faces.partial.render=mainForm%3Aresult_table+mainForm%3ApageNav+mainForm%3AeventAthleteDetailsDialog&mainForm%3Aj_idt363%3A"+ i +"%3Aj_idt365=mainForm%3Aj_idt363%3A"+ i +"%3Aj_idt365&mainForm=mainForm&mainForm%3Araceid=105569&mainForm%3Astatus=results&mainForm%3Aiframe=0&mainForm%3Abib=&mainForm%3Alastname=&mainForm%3Acity=&mainForm%3Afirstname=&mainForm%3Aprovince=&mainForm%3AcategoryFilter=All+Categories", | |
"method": "POST", | |
"mode": "cors" | |
}).then(response => response.text()) | |
.then(str => { | |
fs.writeFile('tri-'+ i +'.xml', str, (err) => { | |
if (err) console.log(err) | |
else console.log('tri-'+ i +'.xml saved') | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment