Portal Home > Knowledgebase > Articles Database > Sample code of opening a URL
Sample code of opening a URL
Posted by hardjoko, 05-22-2007, 04:48 AM |
If I want to open a url say, http://google.com I can use file_get_content
$content=file_get_content("http;//google.com");
How to do the equivalent using curl, socket, socket, and wget?
|
Posted by scribby, 05-22-2007, 08:42 AM |
Curl would be the fastest.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://google.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'UserAgent');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
|
Posted by mwatkins, 05-22-2007, 06:43 PM |
how about It'll tell you to:
wget http://google.com/
Or, in Python:
Last edited by mwatkins; 05-22-2007 at 06:46 PM.
|
Posted by HostingFuze, 05-22-2007, 06:57 PM |
Using php I would use curl but another way is fopen.
|
Add to Favourites Print this Article
Also Read
Compress (Views: 501)
open relay... (Views: 547)