Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: Scan a Page

  1. #1
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Scan a Page

    Is there a way to see if a word is listed on a page? For example, I'd like to know if http://www.ippages.com/voicexml/?ip=71.209.2.19 contains the word "Idaho".

    How can I do this?
    <div> - putting your mind in a box since 1997

  • #2
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    You can use my old search script

    PHP Code:
    <?php
    $uzorak    
    'Idaho';
    $tapeti    file_get_contents("http://www.ippages.com/voicexml/?ip=71.209.2.19");

    work    ($uzorak$tapeti);
    function    
    work($uzorak$tapeti)    {

    $duzina        strlen($uzorak);
    $velicina    strlen($tapeti);

    $b = array();
    $a 0;
    while    (
    $a <= $velicina){
    $newstr    =    substr($tapeti$a$duzina);

    if (
    $newstr == $uzorak){
        
    $isfound "Yes";
        break;
    }
    else {
        
    $isfound "No";
    }
    $a++;
    }
    if (
    $isfound == "Yes") {
        echo 
    "Match found";
    }
    else {
        echo 
    "Sorry, no matches";
    }
    }
    ?>
    It's case sensitive

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    or ...

    PHP Code:
    <?php
    $uzorak 
    'Idaho';
    $tapeti  file_get_contents("http://www.ippages.com/voicexml/?ip=71.209.2.19");
    if(
    strpos($tapeti$uzorak)!==false){
        echo 
    'found it !';
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by firepages View Post
    or ...
    my way is much faster, even though it looks more complicated. try to test it. you'll get interesting result..

  • #5
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts
    Thanks guys. I'm always into smaller code - makes less work when I try to figure out how it works. But, speed-wise, how would I race these two? How is it the longer code would be faster than the compact one?
    <div> - putting your mind in a box since 1997

  • #6
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by ArcticFox View Post
    How is it the longer code would be faster than the compact one?
    I don't know how, i just started the same script with his code, and with my code. His code had a way more lag than my code.

    Can anyone post how to test the time in which the script is executed.

  • #7
    Regular Coder
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    159
    Thanks
    2
    Thanked 15 Times in 15 Posts
    To test the speed of a script:

    Place this code right at the very beginning:
    PHP Code:
    <?php
    function getmicrotime(){
    list(
    $msec,$sec)=explode(" ",microtime());
    return ((float)
    $msec+(float)$sec);
    }
    $started=getmicrotime();
    ?>

    And this code at the very end:
    PHP Code:
    <?php
    $ended
    =round(getmicrotime()-$started,4);
    echo
    "Generated in ".$ended." seconds";
    ?>


    ~Jordan

  • #8
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    OK, guess i was wrong.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •