Ezhil
Ezhil

Reputation: 389

Grabbing content through php curl

iam trying to develop a content grabber using php curl, i need to retrieve content from an url eg:http://mashable.com/2011/10/31/google-reader-backlash-sharebros-petition/ and store it in a csv file. for eg: if i enter a url to extract data, it should store the title, content, tags in the csv and subsequent for the next url. Is their any snippet like that?

the following code generates all the content, i need to specifically call in the title, content of the post

<?php
$homepage = file_get_contents('http://mashable.com/2011/10/28/occupy-wall-street-donations/');
echo strip_tags($homepage);
?>

Upvotes: 0

Views: 1575

Answers (1)

sascha
sascha

Reputation: 4690

There are so many ways. De facto, you want to parse a HTML file. strip_tags is one way, but a dirty one.

I recommend you to use the DOMDocument class for this (There should be many other ways here on so.com). The rest is standard php, writing and reading from a CSV is well documented on php.net

Example for getting links on a website (not by me): http://php.net/manual/en/class.domdocument.php#95894

Upvotes: 1

Related Questions