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 7 of 7

Thread: Web Catching

  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Web Catching

    This is based off of a tut I read, http://www.devhome.org/php/tutorials/webcatching.html

    The problem I'm having is with the $search function. The quotation marks in the font code that I need the script to search between are causing an error message "Parse error: parse error, unexpected T_LNUMBER in line 25"
    Line 25 is
    PHP Code:
    $search eregi("<td><font size="1"><font color="#FFFFFF"><span style="font-weight:normal;">(.*)</span></td>", $read, $money); 
    Is there another way to format it so that it will work correctly?

    PHP Code:
    <?
    $id 
    $_REQUEST['id'] ;
    if (!isset(
    $_REQUEST['id'])) {
    ?>
    <html>
    <head>
    <title>Id Page</title>
    </head>
    <body bgcolor="black" text="green">
    <form method="post" action="outwarid.php">
      ID: <input name="id" type="text" ><br>
      <input type="submit">
    </form>
    </body>
    </html>
    <?
    }
    else {
    $open fopen("http://torax.***********/id.php?id=$id""r"); 

    $read fread($open15000); 

    fclose($open); 

    $search eregi("<td><font size="1"><font color="#FFFFFF"><span style="font-weight:normal;">(.*)</span></td>", $read, $money);  

    $money[1] = str_replace("<br>",""$money[1]);

    $content $money[1];
    $content explode("·"$content); 

    $headlines sizeof($content);

    for (
    $i 0$i $headlines$i++) { 

    print 
    "Money: $content[$i]"


    }

    ?>
    <html>
    <head>
    <title>Test Page</title>
    </head>
    <body bgcolor="black" text="green">
    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You need to escape the quotes, or don't use double quotes.

    PHP Code:
    $search eregi("<td><font size="1"><font color="#FFFFFF"><span style="font-weight:normal;">(.*)</span></td>", $read, $money); 
    ...becomes...

    PHP Code:
    $search eregi("<td><font size=\"1\"><font color=\"#FFFFFF\"><span style=\"font-weight:normal;\">(.*)</span></td>"$read$money); 
    ...or...

    PHP Code:
    $search eregi('<td><font size="1"><font color="#FFFFFF"><span style="font-weight:normal;">(.*)</span></td>'$read$money); 
    Hope that helps.

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, that worked perfectly.

    Now I've come into a new problem. The page that is being searched has multiple instances of the same code but the numbers, which change, are different and I need the first number(512)
    Ex.
    Code:
    <td><font size=\"1\"><font color=\"#FFFFFF\"><span style=\"font-weight:normal;\">512</span></td>
    <td><font size=\"1\"><font color=\"#FFFFFF\"><span style=\"font-weight:normal;\">256</span>
    When I use this to search the file
    PHP Code:
    $search eregi("<td><font size=\"1\"><font color=\"#FFFFFF\"><span style=\"font-weight:normal;\">(.*)</span>"$read$money); 
    It will give something like this
    Code:
    512</span></td>
    <td><font size=\"1\"><font color=\"#FFFFFF\"><span style=\"font-weight:normal;\">256
    Is there a way to tell the search to stop at the first "</span>"?
    Last edited by PureMisery; 12-30-2005 at 09:09 PM.

  • #4
    New Coder
    Join Date
    Dec 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ignore this post now, a stupid mistake I made.
    Last edited by PureMisery; 12-31-2005 at 04:56 AM.

  • #5
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Try
    PHP Code:
    preg_match('#followers\.php\?id=(.*?)">UNDERLINGS#'$read$id);
    //instead of
    eregi("followers.php?(.*)\">UNDERLINGS</a>"$read$id); 
    If this doesn't help, try to read the FULL file, instead of only the first 150'000 bytes.

    Btw., your post-processing of the match doesn't make any sense to me.

    dumpfi

  • #6
    New Coder
    Join Date
    Dec 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dumpfi, thanks for the help but the page I was having that problem with turned out to be unnecessary. Does anyone have some ideas on my problem with the searching?(second post I made)
    Last edited by PureMisery; 12-31-2005 at 04:58 AM.

  • #7
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    Quote Originally Posted by PureMisery
    When I use this to search the file
    PHP Code:
    $search eregi("<td><font size=\"1\"><font color=\"#FFFFFF\"><span style=\"font-weight:normal;\">(.*)</span>"$read$money); 
    It will give something like this
    Code:
    512</span></td>
    <td><font size=\"1\"><font color=\"#FFFFFF\"><span style=\"font-weight:normal;\">256
    Is there a way to tell the search to stop at the first "</span>"?
    Change the part you quoted to this:
    PHP Code:
    $search eregi("<td><font size=\"1\"><font color=\"#FFFFFF\"><span style=\"font-weight:normal;\">(.*?)</span>"$read$money); 
    The (subtle) difference is the addition of the question mark to the greedy wildcard match (.*)


  •  

    Posting Permissions

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