| $url = URL to the feed | $cancache= true|false if this can be cached -*/ if ($cancache) { $cached = $this->cacheControl->getCachedContent("feedReader_" . $url); if ($cached !== false) { return $cached; } } if (!function_exists("fget")) { include_once CONS_PATH_INCLUDE . "loadURL.php"; } if (!function_exists("xmlParamsParser")) { include_once CONS_PATH_INCLUDE . "xmlHandler.php"; } $feed = loadURL($url); // reads feed $output = array(); if ($feed !== false) { // valid content $feedXML = new xmlHandler(); // parses into XML $feed = $feedXML->parseXML($feed[1], array(C_XML_RAW => true, C_XML_AUTOPARSE => true, C_XML_LAX => true, C_XML_REMOVECOMMENTS => true)); // locates CHANNEL or channel (could skip this and get only items) $channel = $feed->getNode("CHANNEL"); if ($channel === false) { $channel = $feed->getNode("channel"); } if ($channel !== false) { // found channel $items = $channel[0]->getNode("ITEM");
function initURL(&$startURLList, &$loantinIdList, &$city) { while (count($city) > 0) { $prefix = array_shift($city); $ch = curl_init(); $doc = loadURL($loantinIdList, "http://muachung.vn/danh-muc/c-999999997/deal-dang-ban.html", $ch, $prefix); $xpath = new DOMXpath($doc); $elements = $xpath->query("//a[@class='newButton mLeft5']/@href"); if (!is_null($elements)) { foreach ($elements as $element) { $url = $element->nodeValue; echo "collection :" . $url . "\n"; loadURL($loantinIdList, $url, $ch, $prefix); } } curl_close($ch); } //loadDulich($loantinIdList); }
function getYoutubeViews($code, $simple = true) { # 2015.1.28: <div class="watch-view-count">16,520,660</div> # <itemprop="datePublished" content="2012-03-11"/> # <strong class="watch-time-text">Published on Nov 30, 2011 $html = loadURL('https://www.youtube.com/watch?v=' . $code); if ($html !== false) { $html = $html[1]; $haswvc = strpos($html, '"watch-view-count"', 5000); if ($haswvc > 0) { $initpos = strpos($html, ">", $haswvc); $endpos = strpos($html, "<", $initpos); $return = array(str_replace(".", "", str_replace(",", "", substr($html, $initpos + 1, $endpos - $initpos - 1))), ''); if (!$simple) { $haswvc = strpos($html, '"datePublished"', 100); if ($haswvc > 0) { $initpos = strpos($html, "content=", $haswvc) + 9; $endpos = strpos($html, '"', $initpos); $return[1] = substr($html, $initpos, $endpos - $initpos); if (strlen($return[1]) > 10) { $return[1] = ""; } } else { return "getYoutubeviews: publish date not found"; } } return $return; } else { return "getYoutubeviews:counter not found"; } } else { return "getYoutubeviews:loadURL fail"; } }
} // Make sure that at least one argument was given if ($argc < 2) { exit('Usage: ' . $argv[0] . " [URL] [-f FILE] ...\n"); } // Create the SQS access object $sqs = new AmazonSQS(); // Process each argument for ($i = 1; $i < $argc; $i++) { if ($argv[$i] == '-f') { $urls = file($argv[++$i]); foreach ($urls as $url) { loadURL($sqs, $feedQueueUrl, trim($url)); } } else { loadURL($sqs, $feedQueueUrl, $argv[$i]); } } function loadURL($sqs, $queue, $url) { // Create message $message = json_encode(array('FeedURL' => $url)); // Post message $res = $sqs->send_message($queue, $message); if ($res->isOK()) { print "Posted '{$message}' to queue '{$queue}'\n"; } else { $error = $res->body->Error->Message; print "Could not post message to queue: {$error}\n"; } }
if ($argc < 2) { exit('Usage: ' . $argv[0] . " [URL] [-f FILE] ...\n"); } // Create the SQS access object $sqs = new AmazonSQS(); // Get queue URL $queueURL = $sqs->create_queue(FEED_QUEUE)->body->CreateQueueResult->QueueUrl; // Process each argument for ($i = 1; $i < $argc; $i++) { if ($argv[$i] == '-f') { $urls = file($argv[++$i]); foreach ($urls as $url) { loadURL($sqs, $queueURL, trim($url)); } } else { loadURL($sqs, $queueURL, $argv[$i]); } } function loadURL($sqs, $queue, $url) { // Create message $message = json_encode(array('FeedURL' => $url)); // Post message $res = $sqs->send_message($queue, $message); if ($res->isOK()) { print "Posted '{$message}' to queue '{$queue}'\n"; } else { $error = $res->body->Error->Message; print "Could not post message to queue: {$error}\n"; } }