kode yard
all about C++ and PHP
Tuesday, October 27, 2009
feed finder in php
Here is a php snippet which finds the rss and atom links of a web site by parsing the meta information in the header section of the page.
Feed finder
if(isset($_POST['link']) && (strlen($_POST['link'])>0)) {
include_once('simple_html_dom.php');
$html = file_get_html(trim($_POST['link']));
$feed_type = array('application/rss+xml',
'text/xml',
'application/atom+xml',
'application/x.atom+xml',
'application/x-atom+xml');
foreach($html->find('link') as $element) {
foreach($feed_type as $rs) {
if(strtolower($element->type) == $rs) {
echo "
" . $element->title . "
\n";
echo "
" . $element->href . "
\n";
echo "
" . $element->type . "
\n";
echo "
---------------------
\n";
}
}
}
}
else
{
?>
Link :
}
?>
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment