Created
March 27, 2018 15:56
-
-
Save ravikp7/d473a202356d5a0ab57db5c1276916d3 to your computer and use it in GitHub Desktop.
beaglebone latest images fetch
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
var fs = require('fs') | |
var http = require('http') | |
var file = fs.createWriteStream("file.html"); | |
var request = http.get("http://beagleboard.org/latest-images", function(response) { | |
response.pipe(file); | |
}); |
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
var hs = require('html-parse-stringify') | |
var fs = require('fs') | |
fs.readFile("file.html", "utf8", function(err, data) { | |
var str = hs.parse(data) | |
var arr = str[0].children[1].children[3].children[5].children[1].children[1].children[3].children[1].children[1] | |
.children[1].children[3].children | |
var i = 0; | |
while(i >= 0){ | |
if(arr[i].name=='h3'){ | |
var fileType = arr[i].children[0].content; | |
var j = i; | |
while(arr[j].name != 'ul'){ | |
j++; | |
} | |
var fileLink = arr[j].children[1].children[1].attrs.href; | |
console.log(fileType) | |
console.log(fileLink) | |
} | |
else if(arr[i].name=='p') break; | |
i++; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment