Skip to content

Instantly share code, notes, and snippets.

@xnuk
Created November 20, 2017 11:51
Show Gist options
  • Save xnuk/61ca106d2099f26262f179b5cb614cf5 to your computer and use it in GitHub Desktop.
Save xnuk/61ca106d2099f26262f179b5cb614cf5 to your computer and use it in GitHub Desktop.
const {parse: crawl, SELECTOR, CONVERT, DATA} = require("crawl-it")
const {get} = require("request")
const {parse: json5} = require('json5')
get("http://m.airkorea.or.kr/sub_new/sub11.jsp", (e, r, b) => {
console.log(crawl(b, {
[DATA]: 'script/text()',
[CONVERT]: v => json5('{' +
v.split('var wrapper;')[0].trim()
.replace(/var\s+JSONObject([^=]+)=/g,'$1:')
.replace(/;\r?\n/g,',')
.replace(/;$/,'')
+ '}')
}))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment