需要以下
的帮助我正在使用SwiftHTTP库并尝试使用savefrom.net获取下载链接
例如,只需访问http://sfrom.net/https://youtube.com/watch?v=war0gHL26ns,网站就会将我们重定向到下载链接
但是,响应的输出不包含下载链接,只包含一长串的javascript函数。
var targetURL = "http://sfrom.net/https://youtube.com/watch?v=war0gHL26ns"
var request = HTTPTask()
request.requestSerializer = HTTPRequestSerializer()
request.requestSerializer.headers["Referer"] = "http://en.savefrom.net"
request.GET(targetURL, parameters: nil, success: {(response: HTTPResponse) in
if let data = response.responseObject as? NSData {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println("response: \(str!)") //prints the HTML of the page
}
},failure: {(error: NSError, response: HTTPResponse?) in
})
我没有使用GET,而是尝试了帖子请求,这次模拟点击下载按钮 - http://en.savefrom.net
var postParameters = ["sf_url":"https://youtube.com/watch?v=war0gHL26ns",
"new":"1"]
var postURL = "http://en.savefrom.net/savefrom.php"
var request = HTTPTask()
request.POST(postURL, parameters: postParameters, success: {(response: HTTPResponse) in
if let data = response.responseObject as? NSData {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println("response: \(str!)") //prints the HTML of the page
}
},failure: {(error: NSError, response: HTTPResponse?) in
})
post_output再次返回一长串的javascript函数