1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need ideas for how to check other pages embedded code...

Discussion in 'HTML & Website Design' started by zygote, Nov 4, 2010.

  1. #1
    Hello,
    SEMrush
    I'm currently working on a custom enterprise web 2.0 project which will have its
    users embed our dynamic code into their websites. I need to figure out a way to
    automatically check their pages to ensure they are using our code properly and
    not cheating the system. This is very similar to how recip directories check for
    backlinks to their site from you.

    I'm familiar with most of the process however I've never worked with spiders
    before and I'm assuming that a spider would be my best option. Given my
    description can anyone recommend a good tutorial or codebase to work from
    in order to do this?

    I'm really not interested in buying a pre-made spider. This is a project I want
    to learn from and I need to do this all custom coded.
     
    zygote, Nov 4, 2010 IP
    SEMrush
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    wrote some quick php

    <?php
    // this is really rough crap php code, but it should give you an idea of how it'll work
    // yes, you can detect cURL or whatever and show different javascript but that's just an abusive client
    // and probably one you don't want in the first place...
    
    
    /*
     * DEFINITIONS
     */
           // Your client's page
            $clientUrl = 'http://jquery.com/';
           // Your code, exactly as it should appear
            $yourCode = '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>';
    
    /*
     * CURLY CURLY CURL
     */
    
        $session = curl_init();
        curl_setopt($session, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
        curl_setopt($session, CURLOPT_URL, $clientUrl);
        curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($session, CURLOPT_TIMEOUT, '2');
        $content = curl_exec($session);
        curl_close($session);
    
    /*
     * CHECK IF EXISTS
     */
    
    $p = strpos($content, $yourCode);
    
    if($p !== false) {
            echo "Our code was found on your page.";
    }
    else{
            echo "Our code was not found on your page.";
    }
    ?>
    
    PHP:
    hth. also, please never use the term "custom enterprise web 2.0"...
     
    krsix, Nov 4, 2010 IP
  3. zygote

    zygote Member

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #3
    Thanks for the sample. This is exactly what I was looking to do. And yes... I'll ban that quote from my vocabulary... lol! :D
     
    zygote, Nov 4, 2010 IP
  4. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    np. i use some custom code (kinda, not) like this on a rails site - basically, the basic of the basic boils down to "hit up webpage, check if string x appears in webpage y, do appropriate actions"

    basically, we also run cronjobs that check the site every day or two, and fire off an email to the client if it's missing the code and other stuff. to start out though, just do a quick check after they hit a button or something saying they have added it.
     
    krsix, Nov 4, 2010 IP
  5. zygote

    zygote Member

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #5
    That is pretty much the plan. We will setup a cron every week or so to verify after they initially implement the code.
     
    zygote, Nov 4, 2010 IP