function feeds_crawler_find_next in Feeds Crawler 6
Same name and namespace in other branches
- 6.2 feeds_crawler.module \feeds_crawler_find_next()
1 call to feeds_crawler_find_next()
- feeds_crawler_batch in ./
feeds_crawler.module - Batch callback.
File
- ./
feeds_crawler.module, line 71
Code
function feeds_crawler_find_next($autodetect, $xpath, $raw, $base_url, $html) {
if ($html == 'html') {
$dom = new DOMDocument();
$success = @$dom
->loadHTML($raw);
if (!$success) {
drupal_set_message(t('There was an error parsing the HTML document at %url.', array(
'%url' => $base_url,
)), 'error');
return FALSE;
}
$xml = simplexml_import_dom($dom);
unset($dom);
}
else {
$xml = @new SimpleXMLElement($raw);
}
if ($autodetect && $html == 'xml') {
feeds_include_library('common_syndication_parser.inc', 'common_syndication_parser');
$format = _parser_common_syndication_feed_format_detect($xml);
if ($format) {
$xml
->registerXpathNamespace('atom', 'http://www.w3.org/2005/Atom');
$xpath = 'atom:link[@rel="next"]/@href';
}
else {
$xpath = 'link[@rel="next"]/@href';
}
}
else {
if ($autodetect && $html == 'html') {
$xpath = 'link[@rel="next"]';
}
}
$href = $xml
->xpath($xpath);
unset($xml);
if ($href === FALSE || empty($href)) {
return FALSE;
}
$href = (string) $href[0];
if (strpos($href, 'http') !== 0) {
$href = $base_url . $href;
}
return $href;
}