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!

Working with cURL 1

Status
Not open for further replies.

biobrain

MIS
Jun 21, 2007
90
GB
I want to display some of contents from my one website to an other one live.

I am planing using cURL for this job.

Here is my code for this task

Code:
<?php

// create a new curl resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "[URL unfurl="true"]http://www.telecom.1pk.asia/fileone.php");[/URL]
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// grab URL, and return output
$output = curl_exec($ch);

// close curl resource, and free up system resources
curl_close($ch);

// Print output
echo $output;

?>
Now by doing this I am able to get the whole contents of fileone.php on my second site

I do not want to show the whole page just want to show the contents between the <table></table> tags from my fileone.php on my first site.

Can you please guide me how I can make this selection of specific contents between the <table></table> and print them on my 2nd website
 
a regular expression is the usual solution

Code:
// create a new curl resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "[URL unfurl="true"]http://www.telecom.1pk.asia/fileone.php");[/URL]
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// grab URL, and return output
$output = curl_exec($ch);

// close curl resource, and free up system resources
curl_close($ch);
[red]
//get stuff in table tags 
preg_match('/(<table>.*?</table>)/ismx', $output, $matches);

//output the grabbed stuff
echo $matches[1];[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top