By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

write html source to a file

P: n/a
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?
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"johnathan" <de**@jdcommerce.com> wrote in message news:18**************************@posting.google.c om...
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?

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);
?>
Jul 17 '05 #2

P: n/a
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
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #3

P: n/a
Shawn Wilson <sh***@glassgiant.com> wrote in message news:<3F**************@glassgiant.com>...
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


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?
Jul 17 '05 #4

P: n/a

"johnathan" <de**@jdcommerce.com> wrote in message news:18**************************@posting.google.c om...
Shawn Wilson <sh***@glassgiant.com> wrote in message news:<3F**************@glassgiant.com>...
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


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?


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

-CF
Jul 17 '05 #5

P: n/a
"ChronoFish" <de**@chronofish.com> wrote in message news:<snEBb.52308$dO2.15782@lakeread03>...
"johnathan" <de**@jdcommerce.com> wrote in message news:18**************************@posting.google.c om...
Shawn Wilson <sh***@glassgiant.com> wrote in message news:<3F**************@glassgiant.com>...
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


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?


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

-CF

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.
Jul 17 '05 #6

P: n/a

"johnathan" <de**@jdcommerce.com> wrote in message news:18*************************@posting.google.co m...

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

-CF

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.


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
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.