Jump to content

Need help on copying text


skend0

Recommended Posts

Hi there i tried this wway to copy content from site  but problem is not working as expected.

<?php
class Provider
{
    public $Name;
    public $Url;
    private $_func;
    
    public function __construct($name, $url, $func)
    {
        $this->Name = $name;
        $this->Url = $url;
        $this->_func = Closure::bind($func, $this);
    }

    public function RetrieveUrl()
    {
        $url = call_user_func($this->_func);
        
        return $url;
    }
}

$providers = array();

$providers[] = new Provider("erodvert", "http://redirect.ero-advertising.com/speedclicks/in.php?pid=92999&spaceid=3546546&returnurl=", function () {
    $html = file_get_contents($this->Url);
    
    $regex = "/var\s+s\s+?=\s+?[\'\"](.*)[\'\"]/i";
    preg_match($regex, $html, $matches);

    if ($matches) {
        return "http://redirect.ero-advertising.com".$matches[1];
    }

    return "";
});

$arr = array_map(function ($p) {
    return $p->RetrieveUrl();
}, $providers);

header('Content-type: application/json');
die(json_encode($arr));

I need the script to copy content  lined with red on image, as that content always changes

 

post-205525-0-73080800-1506540501_thumb.png

Link to comment
Share on other sites

I think this is your issue

 

$providers = array();

$providers[] = new Provider("erodvert", "http://redirect.ero-advertising.com/speedclicks/in.php?pid=92999&spaceid=3546546&returnurl=", function () {

$html = file_get_contents($this->Url);

 

You define an array called $providers. Then you append a provider object as a new element in the $providers array. Lastly, you attempt to define the variable $html as the 'Url' property of $this. What is $this? It has no context outside the object. You would have to reference the last element in the $providers array and get the Url property. Why are you even using an array since it seems you have only one element that will be added? Try this

 

$provider = new Provider("erodvert", "http://redirect.ero-advertising.com/speedclicks/in.php?pid=92999&spaceid=3546546&returnurl=", function () {
$html = file_get_contents($provider->Url);

 

In any case verify the contents of $html before running your regex.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.