Settembre
2

Elenco di stringhe user-agent

Alcune note veloci sulle stringhe user-agent.

Una stringa user-agent è una stringa inviata in ogni richiesta HTTP dalle applicazioni client ai server. Una stringa siffatta include utili informazioni circa il tipo e la versione di browser, il sistema operativo, la lingua. La user-agent è una forma di identificazione di un client HTTP, tale identificazione- comunque - può essere modificata e fornire informazioni alterate (per esempio tramite add-on di firefox o altre soluzioni).

Esistono numerosi siti che offrono elenchi di stringhe user-agent, alcuni di questi facilmente accessibili ed aggiornati sono:

http://www.useragentstring.com/
http://www.useragents.org/

Altre informazioni su user-agent qui.

Semplice esempio d’uso con PHP/CURL (estratto):

$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => selectUseragent(), // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );


function selectUseragent() {
$input=array('Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
'Opera/9.52 (X11; Linux i686; U; fr)',
'Opera/9.52 (X11; Linux i686; U; en)',
'Opera/9.52 (Windows NT 6.0; U; en)',
'Mozilla/5.0 (X11; U; Linux x86_64; it; rv:1.9.0.1) Gecko/2008071717 Firefox/3.0.1',
'Mozilla/5.0 (X11; U; Linux x86_64; fr; rv:1.9.0.1) Gecko/2008071222 Firefox/3.0.1',
'Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1',
'Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.0.1) Gecko/2008070400 SUSE/3.0.1-0.1',
'Mozilla/5.0 (X11; U; Linux x86_64; pt-BR; rv:1.9b5) Gecko/2008041515 Firefox/3.0b5',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT) AppleWebKit/525+ (KHTML, like Gecko) Version/3.1.2 Safari/525.21',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR) AppleWebKit/525.19 (KHTML, like Gecko) Version/3.1.2 Safari/525.21',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.50',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; es-AR; rv:1.7.5) Gecko/20041108 Firefox/1.0',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; DFO-MPO Internet Explorer 6.0)',
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0',
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.0.4-1.3.1 Firefox/1.0.4',
'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.6 (KHTML, like Gecko) Safari/125.12');
return $input[array_rand($input)];
}

» Lascia un commento

RSS feed dei commenti a questo articolo. TrackBack URI

Lascia un commento

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Dati articolo