Re: Web fetching script
| From: | Ben Quinn | Date: | Mon, 27 Aug 2001 07:40:47 +0000 |
| Subject: | Re: Web fetching script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64588@lists.php.net to get a copy of this message | ||
G'day Guys
Sorry, i should have explained it better. What i want to do is grab 2
different lots of text from the same page. Say the page had this text
10am
Some text
12pm
Different text
2pm
I want to be able to grab from say 10am to 12pm and store it in $texta and
then grab from 12pm to 2pm and store it in $textb - but with the script i've
pasted below i can only grab one lot of text at a time! to grab 2 lots of
text from the same page i have to have 2 scripts and in the end i've opened
up and closed the page twice! Anyway, any help i can get will be much
appreciated
This is the script i'm using
<?
$GrabURL = "url.txt";
$GrabStart = "start";
$GrabEnd = "stop";
$file = fopen("$GrabURL", "r");
$rf = fread($file, 20000);
$grab = eregi("$GrabStart(.*)$GrabEnd", $rf, $printing);
$printing[1] = str_replace("replacedatestamp", "withnewstamp",
$printing[1]);
fclose($file);
echo $printing[1];
?>
----- Original Message -----
From: "Dave" <dave@hawk-systems.com>
To: "Ben Quinn" <benquinn@optushome.com.au>; <php-general@lists.php.net>
Sent: Wednesday, August 22, 2001 10:57 PM
Subject: RE: [PHP] Web fetching script
> What response are you expecting, and what response are you getting?
>
> assuming your regex is working as expected, you are running it twice to
receive
> the same result into 2 different variables??? why not just copy the
variable
> after
>
> additionally, $printing is filled with the matches of your regex(10 of
them
> according to manual) as such you have to specify which element of
$printing you
> are wanting to print, or you will get the lovely "array" output
>
> I don't understand why the grab variables are there unless you need them
later.
> Without accounting for your regex...
>
> eregi("$GrabStart(.*)$GrabEnd", $rf, $printing);
> echo $printing[1];
> $printingb=$printing;
> echo $printingb[1];
>
> >I have a web fetching script that fetches text from an external URL and I
> >would like to grab two lots of text at the same time - can anyone tell me
> >why this isn't working?
> >
> ><?
> >
> >$GrabURL = "http://grabfile.html";
> >$GrabStart = "start";
> >$GrabEnd = "stop";
> >
> >$file = fopen("$GrabURL", "r");
> >
> >$rf = fread($file, 20000);
> >
> >$grab = eregi("$GrabStart(.*)$GrabEnd", $rf, $printing);
> >
> >echo $printing;
> >
> >rewind($rf);
> >
> >$grab2 = eregi("$GrabStart(.*)$GrabEnd", $rf, $printingb);
> >
> >echo $printingb;
> >
> >fclose($file);
> >
> >?>
> >
> >
>