+if(! function_exists('scrape_meta')) {
+function scrape_meta($url) {
+
+ $ret = array();
+ $s = fetch_url($url);
+
+ if(! $s)
+ return $ret;
+
+ $dom = HTML5_Parser::parse($s);
+
+ if(! $dom)
+ return $ret;
+
+ $items = $dom->getElementsByTagName('meta');
+
+ // get DFRN link elements
+
+ foreach($items as $item) {
+ $x = $item->getAttribute('name');
+ if(substr($x,0,5) == "dfrn-")
+ $ret[$x] = $item->getAttribute('content');
+ }
+
+ return $ret;
+}}
+
+
+if(! function_exists('scrape_vcard')) {
+function scrape_vcard($url) {
+
+ $ret = array();
+ $s = fetch_url($url);
+
+ if(! $s)
+ return $ret;
+
+ $dom = HTML5_Parser::parse($s);
+
+ if(! $dom)
+ return $ret;
+
+ // Pull out hCard profile elements
+
+ $items = $dom->getElementsByTagName('*');
+ foreach($items as $item) {
+ if(attribute_contains($item->getAttribute('class'), 'vcard')) {
+ $level2 = $item->getElementsByTagName('*');
+ foreach($level2 as $x) {
+ if(attribute_contains($x->getAttribute('class'),'fn'))
+ $ret['fn'] = $x->textContent;
+ if((attribute_contains($x->getAttribute('class'),'photo'))
+ || (attribute_contains($x->getAttribute('class'),'avatar')))
+ $ret['photo'] = $x->getAttribute('src');
+ if((attribute_contains($x->getAttribute('class'),'nickname'))
+ || (attribute_contains($x->getAttribute('class'),'uid')))
+ $ret['nick'] = $x->textContent;
+ }
+ }
+ }
+
+ return $ret;
+}}
+