SEO Forums


Chess, Go & Poker Server









                                          
User   Password   remember   (register)  ?

How to use curl to retrieve an url ?

Free online dating

Back to php.


*curler    (2009-04-23)
 
How to use curl to retrieve an url ?


Hi all,

Here is a very simple function to retrieve the content from an url, it uses the CURL function if it does exist only, otherwise the file_get_contents() function is used instead. Useful

<?

function retrieve_url($url)
{

if (substr($url, 0, 7) != 'http://')  $url = 'ht*p://'.$url;


// if curl not installed
if (!function_exists('curl_init'))
{
    return file_get_contents($url);
}

else
{
    // new curl resource
    $ch = curl_init();

    // set url where to download content
    curl_setopt($ch, CURLOPT_URL, $url);

    // set referrer
    curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/");

    // set user agent
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

    // remove header or not : 0 = yes, 1 = no
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // curl may return or print the data : true = return, false = print
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // timeout in seconds
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    // get the content from url
    $content = curl_exec($ch);

    // close the curl resource
    curl_close($ch);

    return $content;

}
}


?>




(more options below)

*darazu    (2010-06-15 19:52:09)
How to use curl to retrieve an url ?

how to use jquery in php


*senibu    (2015-04-17 04:09:59)
3 years ago

Hi. I was thinking about adding a backlink back to your website since both of our websites are based around the same subject. Would you prefer I link to you using your site address:  or website title: . Be sure to let me know at your earliest convenience. Many thanks
north face outlet store ht*p://www.northface-outletstore.us


See also


ficgs
More websites

You must register to see these links, as this is a collaborative page, then you may change the order of the links by clicking the icons before the titles.



admin
Other websites

The following links might be less relevant, please change their ranks if you find them useful.


 cURL and libcurl
curl.haxx
  1. The minor number bump was made because of the many
  2. The most recent stable version of curl is version
 cURL - Wikipedia, the free encyclopedia
en.wikipedia > wiki/CURL

This page was last modified on 12 September 2010 at...

 How to Use Curl Attributes | eHow.com
ehow

To retrieve multiple files, you can give your URL specification a...
Curl is an open-source utility that will retrieve all types of URLs...

 How To Use cURL (in PHP) For Authentication And SSL Communication
blog.taragana > index.php/archive

What is your favorite relational database (RDBMS) for enterprise...
ThreatFire Antivirus Download Free: ThreatFire Antivirus Real-time...

 Ibuildings - Ibuildings blogs > Multithreading in PHP with CURL
ibuildings > blog/archives/811 Multithreading in PHP with CURL

 YUI Library Examples: Connection Manager: Retrieving a Yahoo! Weather RSS Feed
developer.yahoo > yui/examples/connection/weather

Simple Application (included with examples for Layout...
//Within a PHP block: // Since the result is an XML document, the...

 Opening the web and retrieving all the goodies (Yahoo! Developer Network Blog)
developer.yahoo > blog/archives/2008/12/opening the web

 Can I use cURL for a form with GET method? [Archive] - PHPBuilder.com
phpbuilder > board/archive/index.php/t 10330616

Sorry, are you still trying to use GET or have you switched to using...
If the form uses the GET type, then why try POST'ing data?...

 DevNetwork Forums • Information
forums.devnetwork > viewtopic.php?f=14&t=86696

 Bash: curl and redirected url
experts exchange > Programming/Languages/Scripting/Shell/bash/Q 24036525

Hi experts, I know that status=$(curl -s --head...

 EmacsWiki: Oddmuse Mode
emacswiki > emacs/OddmuseMode

But best of all, why not concentrate our efforts in merging the two...
Oddmuse code to support asynchronous process, not just patch, need...
action will show all changes within the specified time...

 Class: Curl::Easy
curb.rubyforge > classes/Curl/Easy

Re-initializes all options previously set on a specified CURL handle...

 Encoding problem using CURL to retrieve XML - Dev Shed
forums.devshed > php development 5/encoding problem using curl to retrieve xml 5

Safari Books Online provides searchable, on-demand access to...
Warburton's the largest independently owned bakery in the UK faced a...
Create the Optimal Architecture for your Critical...

 Fetching remote content with curl | - [ t o i c . o r g ] -
toic > 2008/10/08/fetching remote content with curl

Re: [Xen-users] Question on Starting Centos52 DomU - Xen...
Lately I see lots of problems with bunch of website scripts still...

 cURL - Frequently Asked Questions
curl.netmirror > docs/faq

 PHP: CURL - Manual
php.chinaunix > manual/zh/ref.curl.php

/*================================== Get url content and response...
Do not forget to use the complete path for the cookies...
//you can figure out the rest ! but thought the reg expression is...

 Getting Started with the Twitter API
devx > webdev/Article/40359/1954

stylesheet, shown below, converts the Atom representation of...
If you can take advantage of all of Twitter's power from the free...

 Practical PHP Programming:Your first Curl scripts - IpbWiki
ipbwiki > Practical PHP Programming:Your first Curl scripts

Practical_PHP_Programming:The abridged list of Curl...
IpbWiki: Integration Of Invision Power Board with...
retrieves and outputs the page, but it would be nice to have the...

 Reading a Remote File Using PHP - PHP MySQL Tutorial
php mysql tutorial > wikis/php tutorial/reading a remote file using php.aspx

Creating A Guestbook Using PHP and MySQL ( Part 2...

 Curl and SSL help - error during istallation - Zen Cart Support
zen cart > forum/s

No response to CURL from Fedex server, check CURL...
Zen Cart - putting the dream of business ownership within reach of...

 'Re: RE: Re: Retrieving XML file through an HTTP url requiring athentication' - MARC
marc > ?l=curl and php&m=107342301231320&w=2

Re: RE: Re: Retrieving XML file through an HTTP url requiring...

 PHP: CURL, Client URL Library Functions - Manual
theserverpages > php/manual/en/ref.curl.php

If you want to Curl to follow redirects and you would also like Curl...
function curl_string ($url,$user_agent,$proxy){...

 Use curl to find redirect url of http://www.disney.com - Usenet Forums
usenet forums > php language/23977 use curl find redirect url http www disney co

 Using CURL to get the HTTP status code of a URL - bytes
bytes > groups/php/5230 using curl get http status code url

 piping a url to wget or curl? - Shell Programming and Scripting - The UNIX and Linux Forums
unix > shell programming scripting/27969 piping url wget curl

If your URL is derived from some other command, save it as a variable...
Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and...

 Tutorial : Display no.of Readers using Feedburner API and PHP (curl) | Vision Master Designs
visionmasterdesigns > tutoral display noof rss readers using feedburner api and

Tutorial : Convert Text into transparent PNG Image using PHP...
Tutorial : Creating a Content Management System using PHP/MySQL...

 PHP : Function Reference : CURL, Client URL Library Functions : curl_exec PHP Examples Tutorials References
navioo > php/docs/function.curl exec.php

 6 essential cURL commands for daily use : CodeDiesel
codediesel > tools/6 essential curl commands

function get_delicious_count(info) { //get the number of...
Comments are disabled for this post, but if you have spotted an...

 Get url via http-proxy in php+curl | PHP | Shopzz Blog - Just another programmer weblog
shopzz > 2007/07/21/get url via http proxy in phpcurl.shtml

email ( will not be shown )...

 How to Use CURL With PHP | Code and Coffee
codeandcoffee > 2006/07

 Use curl from PHP - processing response headers
it.toolbox > wiki/index.php/Use curl from PHP processing response headers

 load() Function for PHP - Fetch URL Content
bin co > php/scripts/load

 PHP :: How To Use CUrl
bigresource > PHP

 Practical PHP Programming | TuxRadar
tuxradar > practicalphp/15/10/2

Copyright 2010 Future Publishing Limited (company registered...

 Error when retrieving file contents - CodingForums.com
codingforums > s

 Rick's spam digest :: Spamstopper's notebook -- curl
rickconner > spamweb/tools curl

Vary: Accept-Encoding,User-Agent nnCoection: close...
) has no directory path info in front of it, so we can assume that it...



Response  
  Smilies

Guest name   (optional)       Register for more options.



Trackbacks : If you talked about this article in your blog or website, you may instantly get a backlink 
  There's no trackback at the moment.











 

FICGS message




SEO forums and chat - Search engines optimization



 


Make your profile in the social network :

- Create groups, pages and events.
- Promote your website (free backlink).
- Keep in touch with your friends.
- Discover what your friends think about you.
- And many more features soon...

 


Pagerank       Copy this code to display your site's Pagerank




Write upside down in your blog, anywhere!
(works with Twitter, Facebook, MySpace, Youtube, MSN, Yahoo, Bebo, Hi5...)







FICGS is also a Free Internet Correspondence Games Server.

Here you can play Chess, Go & Poker Texas Holdem online for free in rated class tournaments and a unique world championship.

Free Internet Chess & Go Server


Feel free to link to this page and to FICGS chess server :