本文整理汇总了PHP中Crawler::curl方法的典型用法代码示例。如果您正苦于以下问题:PHP Crawler::curl方法的具体用法?PHP Crawler::curl怎么用?PHP Crawler::curl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crawler
的用法示例。
在下文中一共展示了Crawler::curl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _tryGetItools
private function _tryGetItools($url, $count = 3)
{
$result = Crawler::curl($url);
//$result = file_get_contents(Yii::app()->basePath . '/itools.html');
if ($result) {
phpQuery::newDocumentHtml($result);
$bestLis = pq('#daySelectCon ul.ios_app_list li');
$this->_itoolsSave($bestLis, 11);
$softLis = pq('.ios_box:eq(2)')->find('ul.ios_app_list li');
$this->_itoolsSave($softLis, 12);
return true;
} elseif ($count !== 0) {
$count--;
sleep(1);
return $this->_tryGetItools($url, $count);
}
return false;
}
示例2: _tryGetAishiData
private function _tryGetAishiData($url, $page, $pagesize = 20, $count = 3)
{
$url = $url . '&pageno=' . $page;
$xml = Crawler::curl($url);
$have_utf = false;
if (strpos($xml, 'UTF-8') != false) {
$have_utf = true;
}
if (strpos($xml, 'utf-8') != false) {
$have_utf = true;
}
if ($have_utf == false) {
return array();
}
$xml = simplexml_load_string($xml);
if ($xml) {
//首页banner入库
if ($page == 1 && isset($xml->adlist)) {
$b = 0;
foreach ($xml->adlist->adinfo as $v) {
$banner['title'] = $v->name;
$banner['ranking'] = ++$b;
$banner['type'] = 13;
$banner['searchtime'] = date("Y-m-d H:i:s");
$tongji = new TongjiData();
$tongji->insertData($banner);
}
}
$k = 0;
foreach ($xml->applist->app as $v) {
$datas[$k]['title'] = $v->appname;
$datas[$k]['ranking'] = ($page - 1) * $pagesize + $k + 1;
$k++;
}
return $datas;
} elseif ($count !== 0) {
$count--;
sleep(1);
return $this->_tryGetAishiData($url, $page, $count);
}
return array();
}