1

so I have this issue. I recently made a flash webscraper to grab a video source link. It works in flash, however when I test in the browser I only get a blank canvas... It does not work. I have no idea as to what the problem is... I just started learning actionscript today, so I'm far from the greatest at it.

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;
    }
}
tHeOnEhErE
  • 11
  • 2

1 Answers1

0

It's sandbox problem, read here, if you'll publish as standalone (ex: Air) project it would work

gMirian
  • 651
  • 7
  • 13
  • In case of web app depends of what you are accessing and how ex: crossdomain.xml is configured. workaround is to create web proxy, ex in PHP, simpliest code: put that it on your server (where you can configure crossdomain as you like) and call from AS3 instead of real address. – gMirian Jul 27 '14 at 08:13
  • 1
    It's funny because I only am using ActionScript because PHP is server-side and I needed to load the contents Client-Side. So, it looks like it's back to the drawing board... – tHeOnEhErE Jul 27 '14 at 08:26
  • :D, in this case you can create only one proxy PHP and then use from AS3 in all projects, so IMHO not so big difference ;) – gMirian Jul 27 '14 at 09:06
  • Yeah, but thing is the initial load generates unique links based upon the IP address. So, if I use PHP the ip address the website will use would be my server's and not the users... So I have no idea what to do. – tHeOnEhErE Jul 27 '14 at 09:08
  • If you need the IP adresse, read and pass the IP adress. http://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php – Malte Köhrer Jul 27 '14 at 14:05