I agree with Trevor... but if he manages to nvigate to the page and
try to parse it, he will end up finding the problem Graham said. He is
only reading the first line. He can either use fread or shrink his
regex to #align=right([0-9]*,?[0-9]*)/td# and make a loop using
fgets. The second option is the worse one tough, the website probably
has way more lines matching that criteria... But it works on that
small piece of the source.
On Tue, 28 Sep 2004 14:52:59 -0400, Gryffyn, Trevor
[EMAIL PROTECTED] wrote:
The URL that you're grabbing there is a frameset, it's probably not the
page you want to look at.
When you right-click on the page you want to parse and select View
Source and get the information you posted below, do the same thing but
right-click and select Properties (in IE at least) and it'll tell you
the URL that you're really looking at.
My guess is that you're really parsing this source:
htmlhead
titleRuneScape - the massive online adventure game by Jagex
Ltd/title
meta name=Description content=RuneScape is a massive 3d multiplayer
adventure, with monsters to kill, quests to complete, and treasure to
win. You control your own character who will improve and become more
powerful the more you play.
meta name=Keywords content=Runescape, Jagex, free, games, online,
multiplayer, magic, spells, java, MMORPG, MPORPG, gaming
link rel=shortcut icon href=/favicon.ico type=image/x-icon /
/head
frameset cols=* frameborder=0 border=0
noframes
body bgcolor=black text=white
h3RuneScape/h3
RuneScape is a massive 3d multiplayer adventure, with monsters
to kill, quests to complete, and treasure to win. You control your
own character who will improve and become more powerful the more you
play.
pThis site uses frames, but your browser doesn't support them./p
pTo play Runescape and browse our website, please download a
recent web browser
such as a href='http://www.microsoft.com'Microsoft Internet
Explorer/a or a href='http://www.netscape.com'Netscape/a./p
brbr
pThe Jagex Team./p
/body
/noframes
!--frame src=none.html noresize scrolling=no--
frame src=frame2.cgi?page=title.html noresize scrolling=auto
!--frame src=none.html noresize scrolling=no--
/frameset
/html
Try echo'ing $line and looking at the data you're parsing. I bet it's
what you see above.
-TG
-Original Message-
From: champinoman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 28, 2004 9:47 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: grabbing information from websites
i said i was learning this and didnt really understand it.
so going by what has been said i have come up with the
following but
still doesnt want to work.
heres what i have:
?php
$file = fopen
(http://hiscore.runescape.com/aff/runescape/hiscorepersonal.c
gi?username=champinoman,r);
$line = fgets ($file, 1024);
if
(preg_match('#username=champinomancategory=13.*align=right
(.*)/td#mi',$line,$out))
{
$rune = $out;
}
fclose($file);
print $rune;
?
and the source it is looking at is:
trtdimg src=http://www.runescape.com/img/hiscores/crafting.gif;
valign=bottom width=16 height=16 //tdtdnbsp;/td
tda href=hiscoreuser.cgi?username=champinomancategory=13
class=cCrafting/a/td
td align=right70,277/tdtd align=right
43
/tdtd align=right
53,630
/td/tr
I want it to get the 70,277 and store as $rune
if someone can tell me where im wrong i would be extremely grateful
thank you for your ongoing support.
--
M. Sokolewicz [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
ugh, obviously I'm a bad typer :) The code should be:
preg_match('#username=champinomancategory=13.*align=right(
.*)/td#mi',
$text, $out);
Or using any other patterndelimiter... ;)
M. Sokolewicz wrote:
I thought I clearly stated that for the m modifier you
need to use PCRE
functions!
eg:
preg_match('/username=champinomancategory=13.*align=right(
.*)/td/mi',
$text, $out);
Champinoman wrote:
so does this look right:
eregi
(username=champinomancategory=13.*align=\right\(.*)/td
m,$line,$out))
is that where i am ment to put the 'm' modifier? or am i
still off on
the wrong track?
Graham Cossey [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
From
http://gnosis.cx/publish/programming/regular_expressions.html:
Sometimes you have a programming problem and it seems like the
best
solution is to use regular expressions; now you have two problems.
To me regular expressions are some kind of black art, I've been
programming
for 20 years and until recently have pretty much managed to avoid
them.
The
above URL is a pretty good tutorial.
HTH
Graham
-Original Message-
From: