Created
September 22, 2013 18:59
-
-
Save brickgao/6662745 to your computer and use it in GitHub Desktop.
A sample to get real url from baiduyun
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 http = require('http') | |
var options = { | |
host: 'yun.baidu.com', | |
port: 80, | |
path: '/share/link?shareid=197263&uk=4264834298', | |
method: 'GET' | |
}; | |
var req = http.get(options, function(res) { | |
var pageData = ""; | |
res.setEncoding('UTF-8'); | |
res.on('data', function(chunk) { | |
pageData += chunk; | |
}); | |
res.on('end', function() { | |
var reg = '"md5\\\\":\\\\\\"(.+?)\\\\"'; | |
var md5_s = pageData.match(reg)[1]; | |
var reg2 = 'dlink\\\\":.+?(http.+?' + md5_s + '\?.+?sh=1)'; | |
var raw = pageData.match(reg2)[1]; | |
//console.log(md5_s); | |
//console.log(reg2); | |
raw = raw.replace(/\\/gi, ""); | |
console.log(raw); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment