[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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