-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-scrape.js
22 lines (20 loc) · 1000 Bytes
/
test-scrape.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* eslint-disable indent */
const axios = require("axios");
axios.get("https://www.earthcam.com/usa/newyork/midtown/skyline/?cam=midtown4k")
.then(response => {
console.log(typeof response.data)
// console.log(response.data);
const startJSON = response.data.indexOf("{\"cam\"")
const endJSON = response.data.indexOf("\"related_cams\":") -2stat
console.log(`startJSON: ${startJSON}`);
console.log(`endJSON: ${endJSON}`);
const slicedJSON = response.data.slice(startJSON, endJSON).concat("}");
const parsedJSON = JSON.parse(slicedJSON)
console.log(parsedJSON)
const camName = Object.keys(parsedJSON.cam)[0]
console.log(camName);
console.log(parsedJSON.cam[camName].html5_streamingdomain)
const liveStreamURL = parsedJSON.cam[camName].html5_streamingdomain + parsedJSON.cam[camName].html5_streampath
console.log(liveStreamURL);
})
// https://videos3.earthcam.com/fecnetwork/3983.flv/chunklist_w1167321633.m3u8