Created
July 11, 2013 09:36
-
-
Save firedfox/5974036 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 JS_URL = 'crs.baidu.com/t.js'; | |
var RC_PATTERN = /rc:\[(.*?)\]/; | |
var args = require('system').args; | |
var page = require('webpage').create(); | |
var jsLoader = require('webpage').create(); | |
var pageURL = args[1]; | |
jsLoader.customHeaders = { | |
'Referer': pageURL | |
}; | |
page.onResourceReceived = function(res) { | |
if (res.url.indexOf(JS_URL) > -1) { | |
jsLoader.open(res.url, function() { | |
var rcMatch = jsLoader.content.match(RC_PATTERN); | |
if (rcMatch) { | |
console.log(rcMatch[1]); | |
} | |
phantom.exit(); | |
}); | |
} | |
}; | |
page.open(pageURL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment