capture a webpage to later process it

capture a webpage to later process it

am 29.04.2006 02:47:59 von buzon

I want to read the results of an URL address, to later process it and
insert part of them as internal code.

If I use include or require, they inserts ALL the resulting code, but I
want to do something like:


blah, blah, blah....
$result_webpage = somephpfunc('http://other.sit/externalpage.html');
if
(eregi("result:([:alnum:]+).*([:alnum:]+\.jpg)",$result_webp age,$array_match))
{ echo "

External status:".$array_match[1]."
image: src=\""..$array_match[2]."\">

"; }
?>
..... blah, blah, blah


TIA,

,_,
(O,O) J. Alejandro Ceballos Z. buzon@alejandro.ceballos.info
( )
-"-"-------------------------------------------------------- ---------
http://alejandro.ceballos.info movil: (33) 3849-8936

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: capture a webpage to later process it

am 29.04.2006 04:46:48 von John Hicks

J. Alejandro Ceballos Z. -JOAL- wrote:
>
> I want to read the results of an URL address, to later process it and
> insert part of them as internal code.
>
> If I use include or require, they inserts ALL the resulting code, but I
> want to do something like:
>
>
> blah, blah, blah....
> > $result_webpage = somephpfunc('http://other.sit/externalpage.html');
> if
> (eregi("result:([:alnum:]+).*([:alnum:]+\.jpg)",$result_webp age,$array_match))
>
> { echo "

External status:".$array_match[1]."
image: > src=\""..$array_match[2]."\">

"; }
> ?>
> .... blah, blah, blah

If you have fopen wrappers enabled (see
http://us2.php.net/manual/en/ref.filesystem.php#ini.allow-ur l-fopen)
then you can simply use file_get_contents() to read the web page into a
string. You can then manipulate it with regexes like so:

$Url = 'http://www.php.net';
$ThePageContents = file_get_contents($Url);
$TheNewPageContents = preg_replace('/PHP/', 'Ruby :)', $ThePageContents);
echo $TheNewPageContents;

--J

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: capture a webpage to later process it

am 29.04.2006 09:09:24 von John Hicks

John Hicks wrote:
> J. Alejandro Ceballos Z. -JOAL- wrote:
>>
>> I want to read the results of an URL address, to later process it and
>> insert part of them as internal code.
>>
>> If I use include or require, they inserts ALL the resulting code, but
>> I want to do something like:
>>
>>
>> blah, blah, blah....
>> >> $result_webpage = somephpfunc('http://other.sit/externalpage.html');
>> if
>> (eregi("result:([:alnum:]+).*([:alnum:]+\.jpg)",$result_webp age,$array_match))
>>
>> { echo "

External status:".$array_match[1]."
image: >> src=\""..$array_match[2]."\">

"; }
>> ?>
>> .... blah, blah, blah
>
> If you have fopen wrappers enabled (see
> http://us2.php.net/manual/en/ref.filesystem.php#ini.allow-ur l-fopen)
> then you can simply use file_get_contents() to read the web page into a
> string. You can then manipulate it with regexes like so:
>
> $Url = 'http://www.php.net';
> $ThePageContents = file_get_contents($Url);
> $TheNewPageContents = preg_replace('/PHP/', 'Ruby :)', $ThePageContents);
> echo $TheNewPageContents;
>
> --J
>

Here's a more useful use of the same idea:

if (isset($Url)) {
$ThePageContents = file_get_contents($Url);
$TheNewPageContents =
preg_replace(
'/(]*>)/',
"\1",
$ThePageContents);
echo $TheNewPageContents;
} else {
echo "Enter a URL as a query string in this URL, e.g.:


http://${_SERVER['SERVER_NAME']}${_SERVER['PHP_SELF']}?Url=h ttp://www.yahoo.com
";
}
?>

This allows you to run your own rather sloppy proxy. Just plug the url
you want into the query string for your page (or, better still, make a
form to post it):

https://mydomain.com/mypage.php?Url=http://DomainIWantToView .com/PageIWantToView.html

The regex adds a tag to the remote web page to make the images
and links work.

But of course, that means the gets of all the images, css, js, etc. will
all show up with your workstation IP on the remote server's log (and on
your boss's log of your browsing), so you haven't really accomplished
much :(

But it's kind of fun, huh?

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: capture a webpage to later process it

am 02.05.2006 03:56:52 von Alejandro Tesone

------=_Part_12115_18103530.1146535012061
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Maybe you are looking is CURL function.

On 4/29/06, John Hicks wrote:
>
> John Hicks wrote:
> > J. Alejandro Ceballos Z. -JOAL- wrote:
> >>
> >> I want to read the results of an URL address, to later process it and
> >> insert part of them as internal code.
> >>
> >> If I use include or require, they inserts ALL the resulting code, but
> >> I want to do something like:
> >>
> >>
> >> blah, blah, blah....
> >> > >> $result_webpage =3D somephpfunc('http://other.sit/externalpage.html')=
;
> >> if
> >>
> (eregi("result:([:alnum:]+).*([:alnum:]+\.jpg)",$result_webp age,$array_ma=
tch))
> >>
> >> { echo "

External status:".$array_match[1]."
image: > >> src=3D\""..$array_match[2]."\">

"; }
> >> ?>
> >> .... blah, blah, blah
> >
> > If you have fopen wrappers enabled (see
> > http://us2.php.net/manual/en/ref.filesystem.php#ini.allow-ur l-fopen)
> > then you can simply use file_get_contents() to read the web page into a
> > string. You can then manipulate it with regexes like so:
> >
> > $Url =3D 'http://www.php.net';
> > $ThePageContents =3D file_get_contents($Url);
> > $TheNewPageContents =3D preg_replace('/PHP/', 'Ruby :)',
> $ThePageContents);
> > echo $TheNewPageContents;
> >
> > --J
> >
>
> Here's a more useful use of the same idea:
>
> > if (isset($Url)) {
> $ThePageContents =3D file_get_contents($Url);
> $TheNewPageContents =3D
> preg_replace(
> '/(]*>)/',
> "\1",
> $ThePageContents);
> echo $TheNewPageContents;
> } else {
> echo "Enter a URL as a query string in this URL, e.g.:
>
om\"
> >
> http://${_SERVER['SERVER_NAME']}${_SERVER['PHP_SELF']}?Url=3 D
> http://www.yahoo.com
";
> }
> ?>
>
> This allows you to run your own rather sloppy proxy. Just plug the url
> you want into the query string for your page (or, better still, make a
> form to post it):
>
>
> https://mydomain.com/mypage.php?Url=3Dhttp://DomainIWantToVi ew.com/PageIW=
antToView.html
>
> The regex adds a tag to the remote web page to make the images
> and links work.
>
> But of course, that means the gets of all the images, css, js, etc. will
> all show up with your workstation IP on the remote server's log (and on
> your boss's log of your browsing), so you haven't really accomplished
> much :(
>
> But it's kind of fun, huh?
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

------=_Part_12115_18103530.1146535012061--