Created
May 5, 2019 20:22
-
-
Save yucedagonurcan/266c84ccc44391fc5e3936ef6329241f to your computer and use it in GitHub Desktop.
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
| function exportToJsonFile(jsonData) { | |
| let dataStr = JSON.stringify(jsonData); | |
| let dataUri = | |
| "data:application/json;charset=utf-8," + encodeURIComponent(dataStr); | |
| let exportFileDefaultName = "data.json"; | |
| let linkElement = document.createElement("a"); | |
| linkElement.setAttribute("href", dataUri); | |
| linkElement.setAttribute("download", exportFileDefaultName); | |
| linkElement.click(); | |
| } | |
| var items = $( | |
| "body > div.container > div > div.infinite-container.text-center" | |
| ); | |
| var dates = []; | |
| Array.from(items[0].children).forEach(element => { | |
| var date = $(element) | |
| .find("div.stars-accumulated.text-center") | |
| .text(); | |
| if (date == "") { | |
| console.log(`Item is not found ${element}`); | |
| } else { | |
| dates.push(date.trim()); | |
| } | |
| }); | |
| parsed_dates = dates.map(element => { | |
| parsed_date = element.split(" "); | |
| return { | |
| day: parsed_date[0], | |
| month: parsed_date[1], | |
| year: parsed_date[2] | |
| }; | |
| }); | |
| exportToJsonFile(parsed_dates); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment