Skip to content

Instantly share code, notes, and snippets.

@henryjuan
Created October 10, 2016 09:52
Show Gist options
  • Save henryjuan/a0944b075c2b779da584f42c0eb0e3ad to your computer and use it in GitHub Desktop.
Save henryjuan/a0944b075c2b779da584f42c0eb0e3ad to your computer and use it in GitHub Desktop.
利用 nightmare 取中銀報價
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });
nightmare
.goto('http://www.boc.cn/sourcedb/whpj')
.select('html body div.wrapper div.BOC_main div.publish div div#DefaultMain.main form#historysearchform div.invest_t table tbody tr td select#pjname', '2895')
.click('html body div.wrapper div.BOC_main div.publish div div#DefaultMain.main form#historysearchform div.invest_t table tbody tr td input.search_btn')
.wait(2000)
.evaluate(function () {
return document.querySelector('table:first-child tr.odd').innerText;
})
.end()
.then(function (result) {
console.log(result)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment