Connecting Tech Pros Worldwide Forums | Help | Site Map

write html source to a file

johnathan
Guest
 
Posts: n/a
#1: Jul 17 '05
How can I use a php script running on my web server to read in the
html source from an arbitrary webpage and then write it to a file on
my web server?

ChronoFish
Guest
 
Posts: n/a
#2: Jul 17 '05

re: write html source to a file



"johnathan" <demo@jdcommerce.com> wrote in message news:18c52625.0312051424.2d5efd0a@posting.google.c om...[color=blue]
> How can I use a php script running on my web server to read in the
> html source from an arbitrary webpage and then write it to a file on
> my web server?[/color]


There are a lot of ways to do this. And I'm sure a PHP purist will post over my suggestions, but try this:

First visit php.net - memorize this as your first stop - it is a great resource
http://www.php.net/manual/en/features.remote-files.php
http://www.php.net/manual/en/function.file.php
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.fwrite.php
http://www.php.net/manual/en/function.fclose.php

Then you can write the following:

<?
// website to steal from
$fileArray = file(http://www.example.com/coolpage.html);

//Open file for writing
$fileHandle = fopen("/DestinationPath/DestinationFile.html", "w");

//Dump File
foreach ($fileArray as $line) fwrite($fileHandle, $line);

//Close File
close($fileHandle);
?>


Shawn Wilson
Guest
 
Posts: n/a
#3: Jul 17 '05

re: write html source to a file


johnathan wrote:[color=blue]
>
> How can I use a php script running on my web server to read in the
> html source from an arbitrary webpage and then write it to a file on
> my web server?[/color]

Search php.net for fopen() + related functions.

Shawn
--
Shawn Wilson
shawn@glassgiant.com
http://www.glassgiant.com
johnathan
Guest
 
Posts: n/a
#4: Jul 17 '05

re: write html source to a file


Shawn Wilson <shawn@glassgiant.com> wrote in message news:<3FD49249.DE18BE4@glassgiant.com>...[color=blue]
> johnathan wrote:[color=green]
> >
> > How can I use a php script running on my web server to read in the
> > html source from an arbitrary webpage and then write it to a file on
> > my web server?[/color]
>
> Search php.net for fopen() + related functions.
>
> Shawn[/color]

Thank you for the suggestions. I have been reading about a set of php
functions called curl_init(), curl_exec(), and so on..... i am sure
you guys know about it.
i have successfully used those commands to read raw html source from
websites, but i am now trying to figure out how to use some of the
CURLOPT_* options to view a page that requires userid and password and
is on a secure server. does anybody know how to do this? for example,
how would i use these curl functions in order to view my online bank
account summary?
ChronoFish
Guest
 
Posts: n/a
#5: Jul 17 '05

re: write html source to a file



"johnathan" <demo@jdcommerce.com> wrote in message news:18c52625.0312091547.558dc863@posting.google.c om...[color=blue]
> Shawn Wilson <shawn@glassgiant.com> wrote in message news:<3FD49249.DE18BE4@glassgiant.com>...[color=green]
> > johnathan wrote:[color=darkred]
> > >
> > > How can I use a php script running on my web server to read in the
> > > html source from an arbitrary webpage and then write it to a file on
> > > my web server?[/color]
> >
> > Search php.net for fopen() + related functions.
> >
> > Shawn[/color]
>
> Thank you for the suggestions. I have been reading about a set of php
> functions called curl_init(), curl_exec(), and so on..... i am sure
> you guys know about it.
> i have successfully used those commands to read raw html source from
> websites, but i am now trying to figure out how to use some of the
> CURLOPT_* options to view a page that requires userid and password and
> is on a secure server. does anybody know how to do this? for example,
> how would i use these curl functions in order to view my online bank
> account summary?[/color]

Sounds dangerous and/or illegal. Here's the rope: http://www.php.net/manual/en/ref.curl.php

-CF


johnathan
Guest
 
Posts: n/a
#6: Jul 17 '05

re: write html source to a file


"ChronoFish" <deja@chronofish.com> wrote in message news:<snEBb.52308$dO2.15782@lakeread03>...[color=blue]
> "johnathan" <demo@jdcommerce.com> wrote in message news:18c52625.0312091547.558dc863@posting.google.c om...[color=green]
> > Shawn Wilson <shawn@glassgiant.com> wrote in message news:<3FD49249.DE18BE4@glassgiant.com>...[color=darkred]
> > > johnathan wrote:
> > > >
> > > > How can I use a php script running on my web server to read in the
> > > > html source from an arbitrary webpage and then write it to a file on
> > > > my web server?
> > >
> > > Search php.net for fopen() + related functions.
> > >
> > > Shawn[/color]
> >
> > Thank you for the suggestions. I have been reading about a set of php
> > functions called curl_init(), curl_exec(), and so on..... i am sure
> > you guys know about it.
> > i have successfully used those commands to read raw html source from
> > websites, but i am now trying to figure out how to use some of the
> > CURLOPT_* options to view a page that requires userid and password and
> > is on a secure server. does anybody know how to do this? for example,
> > how would i use these curl functions in order to view my online bank
> > account summary?[/color]
>
> Sounds dangerous and/or illegal. Here's the rope: http://www.php.net/manual/en/ref.curl.php
>
> -CF[/color]


whoa.... well, nevermind if it's illegal. i thought it would be okay
if i am using it to view my own personal information.... thanks
anyway.
ChronoFish
Guest
 
Posts: n/a
#7: Jul 17 '05

re: write html source to a file



"johnathan" <demo@jdcommerce.com> wrote in message news:18c52625.0312101204.43cd651@posting.google.co m...[color=blue][color=green]
> >
> > Sounds dangerous and/or illegal. Here's the rope: http://www.php.net/manual/en/ref.curl.php
> >
> > -CF[/color]
>
>
> whoa.... well, nevermind if it's illegal. i thought it would be okay
> if i am using it to view my own personal information.... thanks
> anyway.[/color]

If you're viewing your own personal information then the legality of it depends on the license agreement you agreed to with your
provider (bank or whatever).

The danger doesn't go away however. You are taking your personal information from an encrypted source to a text source. If the
machine that is doing the "getting" is the same machine that you're viewing from (i.e. localhost) then there probably isn't anything
to worry about.

However if the machine that is doing the "getting" is hosted, then the link from it to your browser can be packet sniffed and it's
also possible that some of the information could end up in the server's logs. Additionally (as proven by RIAA/Verizon) your ISP may
have logged some of the data as well.

-CF


Closed Thread