following random feeds

This commit is contained in:
Friendika
2011-01-23 20:09:34 -08:00
parent 00d2b58358
commit 5be98e3ec8
3 changed files with 91 additions and 3 deletions

View File

@@ -22,6 +22,8 @@ function scrape_dfrn($url) {
foreach($items as $item) {
$x = $item->getAttribute('rel');
if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml'))
$ret['feed_atom'] = $item->getAttribute('href');
if(substr($x,0,5) == "dfrn-")
$ret[$x] = $item->getAttribute('href');
if($x === 'lrdd') {
@@ -135,3 +137,31 @@ function scrape_vcard($url) {
return $ret;
}}
if(! function_exists('scrape_feed')) {
function scrape_feed($url) {
$ret = array();
$s = fetch_url($url);
if(! $s)
return $ret;
$dom = HTML5_Parser::parse($s);
if(! $dom)
return $ret;
$items = $dom->getElementsByTagName('link');
// get Atom link elements
foreach($items as $item) {
$x = $item->getAttribute('rel');
if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml'))
$ret['feed_atom'] = $item->getAttribute('href');
}
return $ret;
}}