[eluser]tkyy[/eluser]
[quote author="Gram3000" date="1282922159"]Cool, Thank you. I'll give it a go.
Do you recommend any Libraries for it, or use it directly with curl?[/quote]
directly with curl. i recommend a
curl class, which you could store seperate to ci or make into a library since that will get annoying writing all the curlopts out every second. here is one that i wrote awhile ago- i usually use this one if i am not using a framework since i have built an entire framework around "web automation" and i have on big controller that i use in an unorthodox method to make curl calls and store data and etc. anyway i don't want to get offtopic here you go.
Code:
<?php
/**
* curl class, for http connections
*/
class curl
{
var $ch;
function init($use_proxy=1)
{
/* setup the curl handle for this session */
$this->ch = curl_init();
/* randomize useragent */
$agent = array( 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)',
'Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.1; .NET CLR 1.1.4322)',
'Opera/9.20 (Windows NT 6.0; U; en)',
'Opera/9.00 (Windows NT 5.1; U; en)',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.50',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.0',
'Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1) Opera 7.02 [en]',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20060127 Netscape/8.1' );
shuffle($agent);
/* set the cookie into the dump folder */
$cookie_path = '/var/www/mygen/cookies/'.uniqid().'.txt';
/* set curl options */
curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->ch,CURLOPT_AUTOREFERER,1);
curl_setopt($this->ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($this->ch,CURLOPT_USERAGENT,$agent[0]);
curl_setopt($this->ch,CURLOPT_TIMEOUT,20);
curl_setopt($this->ch,CURLOPT_COOKIEFILE,$cookie_path);
curl_setopt($this->ch,CURLOPT_COOKIEJAR,$cookie_path);
curl_setopt($this->ch,CURLOPT_COOKIESESSION,1);
curl_setopt($this->ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($this->ch,CURLOPT_SSL_VERIFYPEER,0);
/*
if($use_proxy==1)
{
$ips = file('/var/www/mygen/resources/proxies.txt');
shuffle($ips);
curl_setopt($this->ch,CURLOPT_PROXY,trim($ips[0]));
unset($ips);
}
*/
}
function get($url)
{
curl_setopt($this->ch,CURLOPT_POST,0);
curl_setopt($this->ch,CURLOPT_URL,$url);
$s = curl_exec($this->ch);
return $s;
}
function post($url,$packet)
{
curl_setopt($this->ch,CURLOPT_POST,1);
curl_setopt($this->ch,CURLOPT_URL,$url);
curl_setopt($this->ch,CURLOPT_POSTFIELDS,$packet);
$s = curl_exec($this->ch);
return $s;
}
}