NR03
NR03

Reputation: 41

Execute HTTP Post automatically

I have a free script and I would like to ask if it's possible to replace or automate the search function. For example every hour. Right now I have to press the search button to find new proxies but I want to search automatically and update them in my database, maybe using a cron job.

if(isset($_POST['search'])) {   // hit search button
    $script_start = $pb->microtime_float();

    ob_flush();
    flush();

    $proxylisttype = $pb->returnProxyList($_REQUEST['listtype']);  // make sure request vars are clean
    $sitestoscour  = $pb->returnSitesScour($_REQUEST);             // make sure request vars are clean
    $finallist     = $pb->returnFinalList($sitestoscour);
    $finallist     = $pb->arrayUnique($finallist);                 // eliminate the dupes before moving on
    if(AUTO_BAN == 1) {                                            // remove banned proxies
        $finallist = $pb->autoBan($finallist);
    }
    $script_end    = $pb->microtime_float();                       // stop the timer
}

Upvotes: 3

Views: 197

Answers (1)

Nin
Nin

Reputation: 3020

You can either do it with curl from a php script or command line (or wget). That way you can set the $_POST:

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL, "http://yoururl.com'");
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, "search=your_query");

$result = curl_exec($ch);

curl_close($ch);

Then make that script run every hour by setting up a cron job.

You could also do it with wget:

wget --post-date="search=query" http://yoururl.com

Upvotes: 3

Related Questions