所以我有这个问题。我最近制作了一个flash webscraper来获取视频源链接。它在flash中工作,但是当我在浏览器中测试时,我只得到一个空白的画布......它不起作用。我不知道问题是什么......我今天刚刚开始学习动作脚本,所以我远远不是最伟大的。
import flash.net.*
import flash.events.*;
import flash.display.*;
var theUrl = "http://www.sockshare.com/file/384F14398D224634";
firstStep();
function firstStep() {
var urlReq: URLRequest = new URLRequest(theUrl);
urlReq.method = URLRequestMethod.POST;
var loader: URLLoader = new URLLoader(urlReq);
loader.addEventListener(Event.COMPLETE, onSuccess);
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.load(urlReq);
function onSuccess(e: Event): void {
var theContents1: String = String(loader.data);
var pattern1: RegExp = /<input type="hidden" value="(?P<innertext>.*?)" name="hash">/;
var result1 = pattern1.exec(theContents1);
goToSecond(result1.innertext);
}
}
function goToSecond(hash: String) {
var urlReq2: URLRequest = new URLRequest(theUrl);
urlReq2.method = URLRequestMethod.POST;
var urlVars2: URLVariables = new URLVariables();
urlVars2.hash = hash;
urlVars2.confirm = 'Continue+as+Free+User';
urlReq2.data = urlVars2;
var loader2: URLLoader = new URLLoader(urlReq2);
loader2.addEventListener(Event.COMPLETE, onSuccess2);
loader2.dataFormat = URLLoaderDataFormat.VARIABLES;
loader2.load(urlReq2);
function onSuccess2(e: Event): void {
var theContents2: String = String(loader2.data);
var pattern: RegExp = /playlist%3A%20%27%2F(?P<innertext>.*?)%27%2C%0D%0A%09plugins/;
var result = pattern.exec(theContents2);
var linkp1: String = "http://www.sockshare.com/" + unescape(result.innertext);
finalStep(linkp1);
}
}
function finalStep(finalUrl: String) {
var urlReq3: URLRequest = new URLRequest(finalUrl);
urlReq3.method = URLRequestMethod.POST;
var loader3: URLLoader = new URLLoader(urlReq3);
loader3.addEventListener(Event.COMPLETE, onSuccess3);
loader3.dataFormat = URLLoaderDataFormat.TEXT;
loader3.load(urlReq3);
function onSuccess3(e: Event): void {
var theContents3: String = String(loader3.data);
var pattern2: RegExp = /<media:content url="(?P<innertext>.*?)" type="/;
var result2 = pattern2.exec(theContents3);
var finalLink: String = result2.innertext;
trace(finalLink);
mainText.text = finalLink;
}
}