RE: [PHP] Re: grabbing information from websites
OK, I've tried it out. What is interesting is that the URL you have posted results in the site's 'home' page, for me anyway, which obviously results in no matches for the preg_match. It appears to redirect to http://www.runescape.com/ somehow. I am using the code: http://hiscore.runescape.com/aff/runescape/hiscorepersona l.cgi?username=champinoman"); if (preg_match('#username=champinoman&category=13.*align="right">(.*)#mi', $content,$out)) { echo $out; }else{ echo $content; // <- results in home page } ?> Graham -Original Message- From: champinoman [mailto:[EMAIL PROTECTED] Sent: 29 September 2004 02:04 To: [EMAIL PROTECTED] Subject: Re: [PHP] Re: grabbing information from websites i tried putting in fread() but still getting a blank screen. any other errors in here? http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=ch ampinoman","r"); $line = fread ($file, 1024); if (preg_match('#username=champinoman&category=13.*align="right">(.*)#mi', $line,$out)) { $rune = $out; } fclose($file); print $rune; ?> "Graham Cossey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > fgets() will read in from file until end of line or end of file up to the > No > bytes given. > > Is there an end of line between the "username=chapinoman" and the " align="right">70,277" ? > > If there is a line break then $line will never contain both strings. > > You may need to use fread() instead. > > HTH > > Graham > > -Original Message- > From: champinoman [mailto:[EMAIL PROTECTED] > Sent: 28 September 2004 14:47 > 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: > > $file = fopen > ("http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=ch > ampinoman","r"); > $line = fgets ($file, 1024); > if > (preg_match('#username=champinoman&category=13.*align="right">(.*)#mi', > $line,$out)) > { > $rune = $out; > } > fclose($file); > print $rune; > ?> > > and the source it is looking at is: > > http://www.runescape.com/img/hiscores/crafting.gif"; > valign="bottom" width=16 height=16 /> > class=c>Crafting > 70,277 > 43 > > 53,630 > > > 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=champinoman&category=13.*align="right">(.*)#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=champinoman&category=13.*align="right">(.*)/mi', >>> $text, $out); >>> >>> Champinoman wrote: >>> >>>> so does this look right: >>>> >>>> eregi >>>> > ("username=champinoman&category=13.*align=\"right\">(.*)"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
Re: [PHP] Re: grabbing information from websites
i tried putting in fread() but still getting a blank screen. any other errors in here? http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=champinoman","r";); $line = fread ($file, 1024); if (preg_match('#username=champinoman&category=13.*align="right">(.*)#mi',$line,$out)) { $rune = $out; } fclose($file); print $rune; ?> "Graham Cossey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > fgets() will read in from file until end of line or end of file up to the > No > bytes given. > > Is there an end of line between the "username=chapinoman" and the " align="right">70,277" ? > > If there is a line break then $line will never contain both strings. > > You may need to use fread() instead. > > HTH > > Graham > > -----Original Message- > From: champinoman [mailto:[EMAIL PROTECTED] > Sent: 28 September 2004 14:47 > 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: > > $file = fopen > ("http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=ch > ampinoman","r"); > $line = fgets ($file, 1024); > if > (preg_match('#username=champinoman&category=13.*align="right">(.*)#mi', > $line,$out)) > { > $rune = $out; > } > fclose($file); > print $rune; > ?> > > and the source it is looking at is: > > http://www.runescape.com/img/hiscores/crafting.gif"; > valign="bottom" width=16 height=16 /> > class=c>Crafting > 70,277 > 43 > > 53,630 > > > 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=champinoman&category=13.*align="right">(.*)#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=champinoman&category=13.*align="right">(.*)/mi', >>> $text, $out); >>> >>> Champinoman wrote: >>> >>>> so does this look right: >>>> >>>> eregi >>>> > ("username=champinoman&category=13.*align=\"right\">(.*)"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: champinoman [mailto:[EMAIL PROTECTED] >>>>> Sent: 28 September 2004 09:35 >>>>> To: [EMAIL PROTECTED] >>>>> Subject: [PHP] Re: grabbing information from websites >>>>> >>>>> >>>>> >>>>> >>>>>> instead of the POSIX regexp, tr using PERL style RegExps >>>>>> (www.php.net/pcre) Once you've done that, you can add the pattern >>>>>> modifier >>>>>> 'm' to allow multilines . >>>>> >>>>> >>>>> i think im lost now. i had a look at the site but im not sure what im >>>>> looking at. any chance u could make a mock script up so i can see what >>>>> your >>>>> explaining? >>>>> >>>>> -- >>>>> PHP General Mailing List (http://www.php.net/) >>>>> To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: grabbing information from websites
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]*)# 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: > > > RuneScape - the massive online adventure game by Jagex > Ltd > > > > > > > >RuneScape >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. >This site uses frames, but your browser doesn't support them. >To play Runescape and browse our website, please download a > recent web browser >such as Microsoft Internet > Explorer or Netscape. > >The Jagex Team. > > > > > > > > > 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: > > > > > $file = fopen > > ("http://hiscore.runescape.com/aff/runescape/hiscorepersonal.c > > gi?username=champinoman","r"); > > $line = fgets ($file, 1024); > > if > > (preg_match('#username=champinoman&category=13.*align="right"> > > (.*)#mi',$line,$out)) > > { > > $rune = $out; > > } > > fclose($file); > > print $rune; > > ?> > > > > and the source it is looking at is: > > > > http://www.runescape.com/img/hiscores/crafting.gif"; > > valign="bottom" width=16 height=16 /> > > > class=c>Crafting > > 70,277 > > 43 > > > > 53,630 > > > > > > 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=champinoman&category=13.*align="right">( > > .*)#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=champinoman&category=13.*align="right">( > > .*)/mi', > > >> $text, $out); > > >> > > >> Champinoman wrote: > > >> > > >>> so does this look right: > > >>> > > >>> eregi > > >>> > > ("username=champinoman&category=13.*align=\"right\">(.*)" > > 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 P
RE: [PHP] Re: grabbing information from websites
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: RuneScape - the massive online adventure game by Jagex Ltd RuneScape 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. This site uses frames, but your browser doesn't support them. To play Runescape and browse our website, please download a recent web browser such as Microsoft Internet Explorer or Netscape. The Jagex Team. 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: > > $file = fopen > ("http://hiscore.runescape.com/aff/runescape/hiscorepersonal.c > gi?username=champinoman","r"); > $line = fgets ($file, 1024); > if > (preg_match('#username=champinoman&category=13.*align="right"> > (.*)#mi',$line,$out)) > { > $rune = $out; > } > fclose($file); > print $rune; > ?> > > and the source it is looking at is: > > http://www.runescape.com/img/hiscores/crafting.gif"; > valign="bottom" width=16 height=16 /> > class=c>Crafting > 70,277 > 43 > > 53,630 > > > 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=champinoman&category=13.*align="right">( > .*)#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=champinoman&category=13.*align="right">( > .*)/mi', > >> $text, $out); > >> > >> Champinoman wrote: > >> > >>> so does this look right: > >>> > >>> eregi > >>> > ("username=champinoman&category=13.*align=\"right\">(.*)" > 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: champinoman [mailto:[EMAIL PROTECTED] >>>> Sent: 28 September 2004 09:35 >>>> To: [EMAIL PROTECTED] >>>> Subject: [PHP] Re: grabbing information from websites >>>> >>>> >>>> >>>> >>>>> instead of the POSIX regexp, tr using PERL style RegExps >>>>> (www.php.net/pcre) Once you've done that, you can add the pattern >>>>> modifier >>>>> 'm' to allow multilines . >>>> >>>> >>>> i think im lost now. i had a look at the site but im not sure what im >>>> looking at. any chance u could make a mock script up so i can see what >>>> your >>>> explaining? >>>> >>>> -- >>>> PHP General Mailing List (http://www.php.net/) >>>> To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: grabbing information from websites
fgets() will read in from file until end of line or end of file up to the No bytes given. Is there an end of line between the "username=chapinoman" and the "70,277" ? If there is a line break then $line will never contain both strings. You may need to use fread() instead. HTH Graham -Original Message- From: champinoman [mailto:[EMAIL PROTECTED] Sent: 28 September 2004 14:47 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: http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=ch ampinoman","r"); $line = fgets ($file, 1024); if (preg_match('#username=champinoman&category=13.*align="right">(.*)#mi', $line,$out)) { $rune = $out; } fclose($file); print $rune; ?> and the source it is looking at is: http://www.runescape.com/img/hiscores/crafting.gif"; valign="bottom" width=16 height=16 /> Crafting 70,277 43 53,630 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=champinoman&category=13.*align="right">(.*)#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=champinoman&category=13.*align="right">(.*)/mi', >> $text, $out); >> >> Champinoman wrote: >> >>> so does this look right: >>> >>> eregi >>> ("username=champinoman&category=13.*align=\"right\">(.*)"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: champinoman [mailto:[EMAIL PROTECTED] >>>> Sent: 28 September 2004 09:35 >>>> To: [EMAIL PROTECTED] >>>> Subject: [PHP] Re: grabbing information from websites >>>> >>>> >>>> >>>> >>>>> instead of the POSIX regexp, tr using PERL style RegExps >>>>> (www.php.net/pcre) Once you've done that, you can add the pattern >>>>> modifier >>>>> 'm' to allow multilines . >>>> >>>> >>>> i think im lost now. i had a look at the site but im not sure what im >>>> looking at. any chance u could make a mock script up so i can see what >>>> your >>>> explaining? >>>> >>>> -- >>>> PHP General Mailing List (http://www.php.net/) >>>> To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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: http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=champinoman","r";); $line = fgets ($file, 1024); if (preg_match('#username=champinoman&category=13.*align="right">(.*)#mi',$line,$out)) { $rune = $out; } fclose($file); print $rune; ?> and the source it is looking at is: http://www.runescape.com/img/hiscores/crafting.gif"; valign="bottom" width=16 height=16 /> Crafting 70,277 43 53,630 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=champinoman&category=13.*align="right">(.*)#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=champinoman&category=13.*align="right">(.*)/mi', >> $text, $out); >> >> Champinoman wrote: >> >>> so does this look right: >>> >>> eregi >>> ("username=champinoman&category=13.*align=\"right\">(.*)"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: champinoman [mailto:[EMAIL PROTECTED] >>>> Sent: 28 September 2004 09:35 >>>> To: [EMAIL PROTECTED] >>>> Subject: [PHP] Re: grabbing information from websites >>>> >>>> >>>> >>>> >>>>> instead of the POSIX regexp, tr using PERL style RegExps >>>>> (www.php.net/pcre) Once you've done that, you can add the pattern >>>>> modifier >>>>> 'm' to allow multilines . >>>> >>>> >>>> i think im lost now. i had a look at the site but im not sure what im >>>> looking at. any chance u could make a mock script up so i can see what >>>> your >>>> explaining? >>>> >>>> -- >>>> PHP General Mailing List (http://www.php.net/) >>>> To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: grabbing information from websites
ugh, obviously I'm a bad typer :) The code should be: preg_match('#username=champinoman&category=13.*align="right">(.*)#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=champinoman&category=13.*align="right">(.*)/mi', $text, $out); Champinoman wrote: so does this look right: eregi ("username=champinoman&category=13.*align=\"right\">(.*)"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: champinoman [mailto:[EMAIL PROTECTED] Sent: 28 September 2004 09:35 To: [EMAIL PROTECTED] Subject: [PHP] Re: grabbing information from websites instead of the POSIX regexp, tr using PERL style RegExps (www.php.net/pcre) Once you've done that, you can add the pattern modifier 'm' to allow multilines . i think im lost now. i had a look at the site but im not sure what im looking at. any chance u could make a mock script up so i can see what your explaining? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: grabbing information from websites
I thought I clearly stated that for the m modifier you need to use PCRE functions! eg: preg_match('/username=champinoman&category=13.*align="right">(.*)/mi', $text, $out); Champinoman wrote: so does this look right: eregi ("username=champinoman&category=13.*align=\"right\">(.*)"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: champinoman [mailto:[EMAIL PROTECTED] Sent: 28 September 2004 09:35 To: [EMAIL PROTECTED] Subject: [PHP] Re: grabbing information from websites instead of the POSIX regexp, tr using PERL style RegExps (www.php.net/pcre) Once you've done that, you can add the pattern modifier 'm' to allow multilines . i think im lost now. i had a look at the site but im not sure what im looking at. any chance u could make a mock script up so i can see what your explaining? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: grabbing information from websites
so does this look right: eregi ("username=champinoman&category=13.*align=\"right\">(.*)"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: champinoman [mailto:[EMAIL PROTECTED] > Sent: 28 September 2004 09:35 > To: [EMAIL PROTECTED] > Subject: [PHP] Re: grabbing information from websites > > > >> instead of the POSIX regexp, tr using PERL style RegExps >> (www.php.net/pcre) Once you've done that, you can add the pattern >> modifier >> 'm' to allow multilines . > > i think im lost now. i had a look at the site but im not sure what im > looking at. any chance u could make a mock script up so i can see what > your > explaining? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: grabbing information from websites
>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: champinoman [mailto:[EMAIL PROTECTED] Sent: 28 September 2004 09:35 To: [EMAIL PROTECTED] Subject: [PHP] Re: grabbing information from websites > instead of the POSIX regexp, tr using PERL style RegExps > (www.php.net/pcre) Once you've done that, you can add the pattern modifier > 'm' to allow multilines . i think im lost now. i had a look at the site but im not sure what im looking at. any chance u could make a mock script up so i can see what your explaining? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: grabbing information from websites
where abouts am i putting the modifier 'm' in the expression to allow the multilines? "Champinoman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >> instead of the POSIX regexp, tr using PERL style RegExps >> (www.php.net/pcre) Once you've done that, you can add the pattern >> modifier 'm' to allow multilines . > > i think im lost now. i had a look at the site but im not sure what im > looking at. any chance u could make a mock script up so i can see what > your explaining? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: grabbing information from websites
Champinoamn wrote: hi everyone, im fairly new to php scripting and was having trouble grabing information from a website. i have been able to grab information that is in amongst other text (for example, the word firemaking below) --- Firemaking 7,386 61 333,575 --- but the number i want to grab is the 61. its on its own line which i think is the reason im having trouble. i have been using this: eregi ("username=champinoman&category=13.*align=\"right\">(.*)",$line,$out) what am i doing wrong? have i posted enough information. thank you for the help. p.s. try and keep the answers fairly straight forward as i am new to this instead of the POSIX regexp, tr using PERL style RegExps (www.php.net/pcre) Once you've done that, you can add the pattern modifier 'm' to allow multilines . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: grabbing information from websites
> instead of the POSIX regexp, tr using PERL style RegExps > (www.php.net/pcre) Once you've done that, you can add the pattern modifier > 'm' to allow multilines . i think im lost now. i had a look at the site but im not sure what im looking at. any chance u could make a mock script up so i can see what your explaining? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Grabbing the STDOUT
Brent Clark wrote: Hi all Ive been try for sometime now, and too tried googling for an answer, to grab the STDOUT of a command. In this case the binary command is readbar The general output of readbar executed on its own is as so: Code 39->10005802 IATA 2 of 5->2 IATA 2 of 5->8 1 barcodes found I basically need to grab this output. Does anyone know how to send this to an array or varible. You want to try shell_exec: http://www.php.net/manual/en/function.shell-exec.php I haven't used readbar, but if it returns plain text then PHP should be able to get the return result, like: $result = shell_exec('readbar'); Some things to consider though: do you want your webserver to have permission to execute shell commands? This COULD be a security risk, so be careful - watch your permissions. Another option is to run the readbar command from the command line and then pipe the result to PHP. I don't really know what you're trying to do here so I can't give better advice than that. I too have tried the passthru function. Kind Regards and thanks to anyone that can help Brent Clark $dirfile = opendir("/var/www/html/davies/Scanned"); while(($row = readdir($dirfile)) == TRUE){ clearstatcache(); if($row != "." && $row != ".." && (substr($row,0,4) == "scan")){ $filearray[] = $row; } } if($row == True){ closedir($row); } foreach($filearray as $var => $key){ system("/usr/sbin/readbar $key 2>%1"); } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Grabbing
I guess the ereg() will stop when i reads a new line character, therefore try to use the preg_match() with /is modifiers. preg_match("/$begin(.*?)$end", $search, $matches); "Daniel alsén" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > iam trying to grab info from a webpage. > > This snippet is the part that does the actual searching... > > $site = "www.whatever.com/something.html"; > $open = fopen($site, "r"); > $search = fread($open, 2); > fclose($open); > $search = ereg("$begin(.*)$end", $search, $content); > > What i find strange is that the search only works on the actual text in the > html-document. It doesn´t seem to be able to use htmltags as $begin or $end. > > And another question: does the "search" of $end begins from $begin? Or does > it scan the whole document for both strings? > > Regards > # Daniel Alsén| www.mindbash.com # > # [EMAIL PROTECTED] | +46 704 86 14 92 # > # ICQ: 63006462 | # > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Grabbing all files and adding to select boxes...
echo "\n"; $dir = opendir('/path/to/images/dir') or die("Could no open images dir."); while ($d = readdir($dir)){ if ($d != '.' && $d != '..'){ echo "$d\n"; } } echo "\n"; -- WARNING [EMAIL PROTECTED] address is an endangered species -- Use [EMAIL PROTECTED] Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm - Original Message - From: Jeff Lewis <[EMAIL PROTECTED]> Newsgroups: php.general To: <[EMAIL PROTECTED]> Sent: Thursday, August 30, 2001 12:24 PM Subject: Grabbing all files and adding to select boxes... I want to open a particular directory that stores images and I want the images to be added to drop down box, was wondering if someone could help me with some code for that. I want to set it up this way so that people can just upload images there and they would be available on each load of the page. Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]