Script to Search lines on source code

Discussion in 'Programming' started by ofir12, Mar 27, 2010.

  1. #1
    Hey,

    I want to make script that search on source code ..

    for example if I set to find 'search' on google.com it will show FOUND.

    Anyone know this kind of script ?

    Thank you
     
    ofir12, Mar 27, 2010 IP
  2. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to follow these steps.
    [1] Scrape the contents of the given url
    See How to scrap links on a web page using PHP
    [2] Use stristr command in php to find the string you want. See following example.
    
    $a = "i am a string and someone wants to search 'to be searched' "; 
    
    $targetstring = "to be searched"; 
    
    if(stristr($a, $targetstring) === TRUE) { 
          echo "string found" ;
    }
    
    PHP:
     
    NeoCambell, Mar 27, 2010 IP
  3. ofir12

    ofir12 Peon

    Messages:
    424
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you for your reply,

    This is my code for now :

    <?php
    $homepage = file_get_contents('http://google.com/');
    
    $homepage = htmlspecialchars($homepage);
    
    $targetstring = "x";
    
    if (stristr($homepage, $targetstring) === FALSE) 
      echo "Not Found !";
    else
      echo "Found !";
    
    ?>
    Code (markup):
    Very simple...

    How can I make it (this code) connect to website from Proxy or fake my user agent to the User IP wont be banned ?, the script will refresh itself every minute. (I dont store the content of the page - its an online check)

    Kindly try to help.

    Thank you in advance.
     
    ofir12, Apr 2, 2010 IP
  4. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    NeoCambell, Apr 2, 2010 IP
  5. ofir12

    ofir12 Peon

    Messages:
    424
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Its better for me not to use curl ..

    Can you implant this in my code ?
     
    ofir12, Apr 2, 2010 IP
  6. ofir12

    ofir12 Peon

    Messages:
    424
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    OK I did it with your curl code , any way to make it connect with proxy ?
     
    Last edited: Apr 3, 2010
    ofir12, Apr 3, 2010 IP
  7. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    When I read your last post, I had a thought that you are trying to scrap web pages from a PC. Is that so?
    In that case, you would have written a small program in C# to do all that.
    Even in this case, if Internet Explorer can browse web pages correctly, then you don't need to do any proxy settings on the program.

    Since you mentioned "script" in your first post, I thought you are looking for a code that runs on a webserver. No need to consider proxy settings in this case at all.

    However, it seems that you are running the script in a local web server, is that right?
    In this case, check whether your web browser can view web pages and the local web server is configured to allow Internet access.
     
    NeoCambell, Apr 3, 2010 IP