The Birth of User-Agent Rogerdavies

I’ve often seen these SEO tools around that give you your information or position in Google and Yahoo, and I wondered how difficult they would be to write myself. Thankfully, with the power of modern PHP this bit of witchcraft turned out to be fairly straightforward and has led to the birth of user-agent Rogerdavies which I will use to identify any future experiments.

Thanks to some pimping of Wordpress using the Exec-PHP Plugin by Priyadi Iman Nurcahyo, a skillful bit of alchemy which allows you to use the <?php syntax within your Wordpress web pages. As a result, I am proud to be able to offer this tool from the centre of this very blog page!

Simply enter your keyword and URL in the boxes below:

Find My Website in Google and Yahoo Now:

  • URL (without HTTP,
    e.g. ‘rogerdavies.com’) :
  • Search Term :

Fetch Web Pages Without Using fopen from a Shared Hosting Platform

In the end I used the PHP curl_exec(…) command to fetch web pages, which is a neat alternative to fopen which I instinctively tried to use, but failed because my server is on a shared hosting platform. For anyone who wants to know how to fetch web pages with your server on a shared hosting platform (or don’t have access to the php.ini file for any other reason), here is a snippet from my code that shows how it can be done:

 function get_web_page_rog( $url )
{
      $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      => "rogerdavies", // 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 );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;
    return $header;
}


Birth of User-Agent Rogerdavies


Most interestingly, the packet used by curl_exec allows you to pass (among other interesting items) CURLOPT_USERAGENT, specifying the name of the requesting agent. I guess I just put ‘rogerdavies’ as the user agent and this will be what I use for all future tools and should be noted by any developers wishing to be able to identify the fingerprints my toys leave behind, IP Address 81.97.62.218

  • Share/Save/Bookmark