Created
May 23, 2017 03:58
-
-
Save anonymous/85d86addcbf66e7529ba723cb5f1ff74 to your computer and use it in GitHub Desktop.
This file contains 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 page = require('webpage').create() | |
page.onInitialized = function() { | |
page.evaluate(function() { | |
window.callPhantom = undefined | |
window._phantom = undefined | |
}); | |
} | |
page.customHeaders = { | |
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", | |
"User-Agent" : 'Mozilla/5.0 (Android 4.4; Tablet; rv:41.0) Gecko/41.0 Firefox/41.0' | |
} | |
var count = 0 | |
function jump(){ | |
page.evaluate(function () { | |
eval("goUrl('/txnS03.do')"); | |
}); | |
} | |
function fill(sn) { | |
console.log('in fill') | |
sn = typeof(sn) !== "undefined" ? sn : 11111111 | |
page.evaluate(function (sn) { | |
document.getElementsByName("request:sn")[0].click() | |
document.getElementsByName("request:sn")[0].value=sn | |
document.getElementById("_searchButton").click() | |
}, sn) | |
} | |
page.onPageCreated = function(newpage) { | |
newpage.customHeaders = { | |
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", | |
"User-Agent" : 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Thunderbird/1.0.6' | |
} | |
newpage.onInitialized = function() { | |
console.log('newpage init') | |
newpage.evaluate(function() { | |
window.callPhantom = undefined | |
window._phantom = undefined | |
}); | |
} | |
newpage.onLoadFinished = function (){ | |
count += 1 | |
newpage.render('export.png'); | |
console.log(count, newpage.title, newpage.url) | |
//phantom.exit(); | |
} | |
} | |
page.onLoadFinished = function() { | |
count += 1 | |
console.log(count, page.title, page.url) | |
if (count == 2) { | |
jump() | |
} | |
if (count == 3) { | |
setTimeout(function() { | |
fill()}, 2000) | |
} | |
}; | |
page.open('http://wsjs.saic.gov.cn/'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment