...

View Full Version : Web Catching



PureMisery
12-30-2005, 05:13 AM
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
$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?


<?
$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($open, 15000);

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>

Kurashu
12-30-2005, 06:22 AM
You need to escape the quotes, or don't use double quotes.


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

...becomes...


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

...or...


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

Hope that helps.

PureMisery
12-30-2005, 06:56 AM
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.
<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

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

It will give something like this

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>"?

PureMisery
12-30-2005, 09:23 PM
Ignore this post now, a stupid mistake I made.

dumpfi
12-30-2005, 11:51 PM
Try


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

PureMisery
12-31-2005, 12:03 AM
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)

ralph l mayo
12-31-2005, 07:48 PM
When I use this to search the file

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

It will give something like this

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:

$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 (.*)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum