Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using cURL

Status
Not open for further replies.

rjonesX

Technical User
Jun 18, 2001
56
US
I need to just pick up the html of a url using cURL...

Essentially, I need to get the html of, for example


into a variable named

$content

any ideas?
 
This:

Code:
<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "[URL unfurl="true"]http://www.mit.edu/");[/URL]
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$foo = curl_exec($ch);

curl_close($ch);
?>

Will fetch the home page from MIT's website and store the HTML in the variable $foo. If you change

curl_setopt($ch, CURLOPT_HEADER, 0);

to read

curl_setopt($ch, CURLOPT_HEADER, 1);

cURL will fetch HTTP headers, too.

See curl_exec() and curl_setopt() for more information.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top