• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

Request one page

How can we request one page any server and the return value is the content of this page, like
when we request : http://www.yahoo.com in my browser
The content (return value) is on my browser.
But how can I capture it into my Server.
0
longlong
Asked:
longlong
1 Solution
 
anupkaradeCommented:
Your question is not clear...
Do you mean to say that you type url and you get the
required page?? what are you trying to tell pls explain it clearly.
            Anup
0
 
us111Commented:
here is the answer:
$fcontents = join ('', file ('http://www.yahoo.com.net'));

but you cannot get the content of an https (SSL) url, for that you need the curl extension
0
 
higijjCommented:
us111 is right!

here is how for the secure connection using curl extention:

$ch = curl_init();

     curl_setopt ($ch, CURLOPT_URL, "https://www.yoursecureserver.com/");
     curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
     curl_setopt ($ch, CURLOPT_RETURNTRANSFER,1);
     $content = curl_exec($ch);

curl_close($ch);
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
izwizCommented:
It actually sounds like you want to set up a proxy cache on your server to me.
0
 
sweatjeCommented:
I have used code like the following:

$f_contents = array();
$fp = @fopen("http://www.example.com/somepage.php?var=$parm",'r');
while ($line = @fgets($fp, 1024)) {
     $f_contents[] = $line;
}
@fclose($fp);

You can then parse the page and do whatever you like with the output, each line in the page is an item in the $f_contents array.


0
 
us111Commented:
$fcontents = join ('', file ('http://www.yahoo.com.net'));
does the same as sweatie
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now