function get_product($url, $page = 0) { global $save_folder; $html = curl_get($url); //Загружает страницу товара $dom = str_get_html($html); $article = $dom->find('article', 0); //Берем артикул $str = $article->attr['id']; sscanf($str, 'post-%d', $art); $scripts = $dom->find('script'); foreach ($scripts as $script) { if (strpos($script->src, "script.js")) { $str = "script[src='" . $script->src . "']"; } } $dom->find($str, 0)->outertext = ''; //Ajax запрос $html = get_ajax($art); //Получили данные из ajax $dom2 = str_get_html($html); //Ищем в 1-й странице div куда будем вставлять данные из ajax $dom->find('div[id=order-variables]', 0)->innertext = $dom2; //Сохраняем HTML file_put_contents($save_folder . 'product--' . $page . '.html', $dom); }
function normal_sign($uid, $tieba) { $setting = get_setting($uid); $url = "http://tieba.baidu.com/mo/m?kw={$tieba[unicode_name]}"; $get_url = curl_get($url, $uid); if (!$get_url) { return array(1, '无法打开贴吧首页', 0); } $get_url = wrap_text($get_url); preg_match('/<ahref="([^"]*?)">签到<\\/a>/', $get_url, $matches); if (isset($matches[1])) { $s = str_replace('&', '&', $matches[1]); $sign_url = 'http://tieba.baidu.com' . $s; $get_sign = curl_get($sign_url, $uid, $setting['use_bdbowser']); $done++; if (!$get_sign) { return array(1, '签到错误,可能已经签到成功,稍后重试', 0); } $get_sign = wrap_text($get_sign); preg_match('/<spanclass="light">签到成功,经验值上升<spanclass="light">(\\d+)<\\/span>/', $get_sign, $matches); if ($matches[1]) { return array(2, "签到成功,经验值+{$matches[1]}", $matches[1]); } else { return array(1, '签到错误,可能已经签到成功,稍后重试', 0); } } else { preg_match('/<span>已签到<\\/span>/', $get_url, $matches); if ($matches[0]) { return array(2, '此前已成功签到', 0); } else { return array(-1, '找不到签到链接,稍后重试', 0); } } }
function getKuaiDi($ID, $name) { global $kuaidi; include_once HANDLE_DIR . 'libs/pinYin.class.php'; include_once dirname(dirname(dirname(__FILE__))) . '/tools.class.php'; $name = pinYin::convert($name, 'utf8'); /*-------------- 获取内容 -------------*/ $url = $kuaidi['url'] . '?key=' . $kuaidi['key'] . '&order=' . $ID . '&id=' . $name . '&show=xml'; $response = curl_get($url); /*---------------- 结束获取----------------*/ $kuaidiobj = simplexml_load_string($response); //xml解析 $kuaidistatus = $kuaidiobj->Status; //获取快递状态 $kuaistr = strval($kuaidistatus); //对象转换为字符串 $contentStr0 = $kuaidi['statusCode'][$kuaistr]; //根据数组返回 foreach ($kuaidiobj->Data->Order as $a) { foreach ($a->Time as $b) { foreach ($a->Content as $c) { $m .= "{$b}\n{$c}。\n"; } } } //遍历获取快递时间和事件 $contentStr = "你的快递单号{$ID}{$contentStr0}\n{$m}"; return $contentStr; }
function sendsiderr($qq, $sid, $err = 'sid') { global $backurl; curl_get($backurl . 'api.php?my=siderr&qq=' . $qq . '&sid=' . $sid . '&err=' . $err); if (isset($_POST['backurl'])) { curl_get($backurl . 'api.php?my=sendmail&qq=' . $qq . '&sid=' . $sid . '&err=' . $err); } }
function get_mv_info($mv_id) { $url = "http://music.163.com/api/mv/detail?id={$mv_id}&type=mp4"; $output = curl_get($url); $mvs = $output['data']['brs']; $mv = "1080P:" . $mvs['1080'] . "<br>720P:" . $mvs['720'] . "<br>480P:" . $mvs['480'] . "<br>240P:" . $mvs['240']; print_r($mv); }
function get_sport($athlete) { $sports = array("football", "cricket", "badminton", "tennis", "golf"); $max_count = array(0, 0, 0, 0, 0); function curl_get($url) { $return = ''; function_exists('curl_init') ? '' : die('cURL Must be installed!'); $curl = curl_init(); $header[0] = "Accept: text/xml,application/xml,application/json,application/xhtml+xml,"; $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($curl); curl_close($curl); return $result; } foreach ($athlete as $var) { $url = "http://en.wikipedia.org/wiki/" . preg_replace("/ /", '_', $var['name']); $long_url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22" . rawurlencode($url) . "%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2Fdiv%5B%40id%3D%22mw-content-text%22%5D%2Fp%5B1%5D'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback="; $result = curl_get($long_url); $result = preg_split('/([\\s\\-_,:;?!\\/\\(\\)\\[\\]{}<>\\r\\n"]|(?<!\\d)\\.(?!\\d))/', $result, null, PREG_SPLIT_NO_EMPTY); $count = array(0, 0, 0, 0, 0); foreach ($result as $str) { for ($i = 0; $i < 5; $i++) { if ($sports[$i] == $str) { $count[$i]++; } } } $pos = 0; for ($i = 0; $i < 5; $i++) { if ($count[$i] > $count[$pos]) { $pos = $i; } } if ($count[$pos]) { $max_count[$pos]++; } } $pos = 0; for ($i = 0; $i < 5; $i++) { if ($max_count[$i] > $max_count[$pos]) { $pos = $i; } } return $sports[$pos]; }
public function getDataFromNotification($notification_id) { if ($this->sandboxmode) { $url = "ws.sandbox.pagseguro.uol.com.br"; } else { $url = "ws.pagseguro.uol.com.br"; } return json_decode(json_encode(simplexml_load_string(curl_get('https://' . $url . '/v2/transactions/notifications/' . $notification_id, array('email' => $this->email, 'token' => $this->token)))), true); }
function curl_get_json($url, $proxy_server = '', $proxy_port = '', array $get = NULL, array $options = array()) { $options[CURLOPT_HTTPHEADER] = array('Content-Type: application/json'); $result = curl_get($url, $proxy_server, $proxy_port, $get, $options); if ($result['data'] != false && $result['info']['http_code'] == 200) { $result['json'] = json_decode($result['data']); } return $result; }
function gist_detail_raw() { // Lấy chi tiết của 1 gist //$value = "https://gist.githubusercontent.com/vihoangson/89ab60fe9bfa1d34892b/raw/384cfe35243fe625e1b71595ca5ad31c59e662a8/B%C3%AD%20k%C3%ADp%20v%C3%B5%20c%C3%B4ng%201000%20b%C3%A0i%20k%E1%BB%B9%20thu%E1%BA%ADt%20l%E1%BA%ADp%20tr%C3%ACnh%20c%E1%BB%A7a%20Nguy%E1%BB%85n%20T%E1%BA%A5n%20Tr%E1%BA%A7n%20Minh%20Khang.md"; $result = curl_get($value); echo "<pre>"; echo htmlentities($result); echo "</pre>"; }
function request($operation, $data) { $url = "{$this->requestURL}&Operation={$operation}&AWSAccessKeyId={$this->pubKey}&AssociateTag={$this->assocTag}" . $this->buildData($data); $url = $this->getRequest($url); //echo "<a href='$url'>XML</a>"; $response = curl_get($url); $xml = simplexml_load_string($response); return $xml; }
function flickr_api_call($method, $params) { $api_url = FLICKR_URL_BASE; $api_url .= '&api_key=' . FLICKR_API_KEY_PUBLIC; foreach ($params as $key => $value) { $api_url .= '&' . $key . '=' . urlencode($value); } $result_string = curl_get($api_url); $result_xml = simplexml_load_string($result_string); return $result_xml; }
function frontPageFeaturedVideos($baseUrl) { //?source=YouTube&sorts=most_viewed&period=week $source = 'YouTube,Metacafe,Dailymotion'; $sorts = 'most_viewed'; $period = 'week'; $urlToCall = $baseUrl . '/api/getVideos?source=' . $source . '&sorts=' . $sorts . '&period=' . $period; $videos = curl_get($urlToCall); var_dump($videos); die; }
function jokei_txt() { $str = curl_get('http://jokei.aliapp.com/m/api.php?key=hu60&act=txt'); $str = json_decode($str, true); if (!$str) { return randstr(); } $txt = str_replace('[br]', "\r\n", $str['txt']); $title = $str['title']; $str = '《' . $title . '》' . $txt; return $str; }
function apiGo($userName, $cellphone, $openId) { $soureName = 'e2693f6ad8c67d831e5d64785613bb71'; $url = "https://prcws.acxiom.com.cn/PRC/rest/customer/general?obj={'source_name':'" . $soureName . "','username':'******','cellphone':'" . $cellphone . "','openId':'" . $openId . "'}"; $res = curl_get($url); $arr = json_decode($res, true); if ($arr && is_array($arr)) { if ($arr["WS_RESPONSE"]["RETURN_CODE"]) { return $arr["WS_RESPONSE"]["RETURN_CODE"]; } } return false; }
public function bankInfo($card) { if (!$card) { $card = I('get.card'); } $curlUrl = "https://www.zhimale.com/Api/bank/card/" . $card; $res = curl_get($curlUrl); if ($res) { $this->ajaxReturn(array('status' => 1, 'info' => $res)); } else { $this->ajaxReturn(array('status' => 1, 'info' => '')); } }
function DynMapCoords() { $config = array("get" => 'up/world/{world}/', 'send' => 'up/sendmessage'); $worlds = array("mesp"); $players = array(); foreach ($worlds as $world) { $update = json_decode(curl_get("http://mespduendedreams.com:" . intval(arg("dynmap", false)) . "/" . str_replace('{world}', $world, $config['get']) . time()), true); foreach ($update['players'] as $player) { $players[$player['name']] = $player; } } return $players; }
function getMusicLrcById($tempId, $type) { $url = "http://music.163.com/api/song/lyric?os=pc&id=" . $tempId . "&lv=-1&kv=-1&tv=-1"; switch ($type) { case "Json": return curl_get($url); break; case "Obj": return json_decode(curl_get($url)); break; default: break; } }
function get_page_metadata($url) { $html = curl_get($url); $title_ex = '/<title>(?P<title>.*?)<\\/title>/is'; $desc_ex = '/<meta name="description" content="(?P<desc>.*?)"\\/?>/is'; preg_match($title_ex, $html, $titles); preg_match($desc_ex, $html, $descs); $retn = array(); if (count($titles) > 0) { $retn['title'] = $titles['title']; } if (count($descs) > 0) { $retn['desc'] = $descs['desc']; } return $retn; }
function call_curl_reconnect($url, array $data = [], $json = true) { $t_count = 10; $count = $t_count; while ($count) { $result = curl_get($url, $data, $json); if ($result) { return $result; } $slpSecd = intval(sqrt($t_count - $count) * 1000000); dump($slpSecd); usleep($slpSecd); // sleep($seconds); $count--; } }
public function LoadTb($cookieid, $page = 1) { $db = M('SignList'); // 清除当前数据 $db->where('cookieid=%d', $cookieid)->delete(); // 获取Cookie数据 $cookieRes = M('Cookie')->where('id=%d', $cookieid)->find(); $cookie = 'BDUSS=' . $cookieRes['cookies'] . ';'; $username = $cookieRes['username']; $raw_name = GetTbName($cookie); echo $raw_name; if ($raw_name) { $data = array('id' => $cookieid, 'name' => $raw_name . '(正在加载)'); M('Cookie')->save($data); } else { $data = array('id' => $cookieid, 'name' => 'Cookie无效', 'overdue' => 1); M('Cookie')->save($data); return; } // 加载贴吧数据 $count = 0; for ($i = 1;; $i = $i + 1) { $content = curl_get("http://tieba.baidu.com/f/like/mylike?&pn=" . $i, $cookie); $content = mb_convert_encoding($content, 'utf-8', 'gbk'); $reslike = array(); preg_match_all('/title="([\\S]*)".*balvid="([\\d]*)".*balvname="([\\S]*)"/U', $content, $reslike); for ($j = 0; $j < count($reslike[1]); ++$j) { if ($reslike[2][$j] == null) { continue; } $data = array('username' => $username, 'cookieid' => $cookieid, 'fid' => $reslike[2][$j], 'tiebaname' => $reslike[1][$j], 'urlname' => $reslike[3][$j], 'issign' => 2); $db->add($data); } $count += count($reslike[1]); if (count($reslike[1]) == 0) { break; } if ($count > 2000) { break; } } $data = array('id' => $cookieid, 'name' => $raw_name); M('Cookie')->save($data); echo $raw_name . ' 贴吧加载完成,共' . $count . '个贴吧'; }
public function index() { // get newest rates $url = 'http://docs.ookcash.com/api/get_tag_posts/'; $fields = array('slug' => $this->configs['API_POST_HOMEPAGE']); $tags = json_decode(curl_get($url, $fields)); $posts = array(); foreach ($tags->posts as $post) { $data = array('href' => $post->url, 'title' => $post->title, 'content' => substr(strip_tags($post->content), 0, 175), 'thumbnail' => $post->thumbnail); $posts[] = $data; } $this->data['posts'] = $posts; $post_info_url = 'http://docs.ookcash.com/api/get_page/'; $post_info_fields = array('slug' => $this->configs['API_POST_BANNER']); $post_info_object = json_decode(curl_get($post_info_url, $post_info_fields)); $post_info = array('href' => $post_info_object->page->url, 'title' => $post_info_object->page->title, 'content' => $post_info_object->page->content); $this->data['post_info'] = $post_info; $this->view('home'); }
function getLang($filename, $lang) { $tempJson = curl_get(langDirectory . $filename); $tempObj = json_decode($tempJson); //echo $tempObj->lang[0]->name; $i = 0; while ($tempObj->lang[$i]->name != "") { $name = prefix . $tempObj->lang[$i]->name; define($tempObj->lang[$i]->name, $name); global ${$name}; ${$name} = $tempObj->lang[$i]->{$lang}; //当当前语言文本不存在的时候,调用默认语言 if (${$name} == "") { //echo "meiyoudongxi!"; $t = defaultLang; ${$name} = $tempObj->lang[$i]->{$t}; } //echo $name . '=' . $$name . "<br>"; $i++; } }
function processRequest(&$db) { ob_end_clean(); include_once BASE_PATH . "/lib/output.php"; Output::buffer(); $link = "http://mywebsql.net/updates.php?j=1&" . "c=MyWebSQL&l=" . urlencode(LANGUAGE) . "&v=" . urlencode(APP_VERSION) . "&t=" . urlencode(THEME_PATH); // include compact edition in update if we are using one if (defined('MYWEBSQL_COMPACT_DIST')) { $link .= "&e=compact"; } $output = ""; if (ini_get("allow_url_fopen")) { $output = file_get_contents($link); } else { $output = curl_get($link); } Session::set('updates', 'check', '1'); echo $output; $db->disconnect(); Output::flush(); die; }
function get_annotations($subject) { //$topic = $_GET["page"]; $text = ""; global $triples; foreach ($triples as $key => $triple) { if ($triple['s'] == $subject && $triple['p'] == "http://www.w3.org/2000/01/rdf-schema#label") { $label = $triple['o']; } if ($triple['s'] == $subject && $triple['p'] == "http://fahrplan.u0d.de/schema.owl#hasDescription") { $description = $triple['o']; } if (isset($label) && isset($description)) { break; } } $annotated = curl_get("http://spotlight.dbpedia.org/rest/annotate?text=" . urlencode($label) . "&confidence=0.2&support=20"); $dom = new DOMDocument(); $dom->loadXML($annotated); $xpath = new DOMXPath($dom); $tags = $xpath->query('//Resource'); $urls = array(); foreach ($tags as $tag) { array_push($urls, $tag->getAttribute("URI")); } //return $urls; if (sizeof($urls) == 0) { $annotated = curl_get("http://spotlight.dbpedia.org/rest/annotate?text=" . urlencode($description) . "&confidence=0.2&support=20"); $dom = new DOMDocument(); $dom->loadXML($annotated); $xpath = new DOMXPath($dom); $tags = $xpath->query('//Resource'); $urls = array(); foreach ($tags as $tag) { array_push($urls, $tag->getAttribute("URI")); } } return $urls; }
function getId($bduss, $fast) { global $m; $header[] = 'Content-Type:application/x-www-form-urlencoded; charset=UTF-8'; $header[] = 'Cookie: BDUSS=' . $bduss; if ($fast) { $data = curl_get("http://tieba.baidu.com/dc/common/tbs", $header); $data = getMiddle($data, '"is_login":'******'}'); $ret = array(); $ret['valid'] = $data == '1' ? '1' : '0'; //bduss是否有效 $res = $m->query('Select name From ' . DB_PREFIX . 'baiduid Where bduss=\'' . $bduss . "'"); if ($res->num_rows != 0) { //如果该bduss在数据库里有记录 $row = $m->fetch_array($res); $ret['name'] = $row['name']; } else { $ret['name'] = $data == '1' ? '有效' : '无效'; } } else { $data = curl_get("http://wapp.baidu.com/", $header); $name = urldecode(getMiddle($data, 'i?un=', '">')); $ret = array(); $ret['valid'] = $name == '' ? '0' : '1'; if ($ret['valid']) { $ret['name'] = $name; } else { $res = $m->query('Select name From ' . DB_PREFIX . "baiduid Where bduss='" . $bduss . "'"); if ($res->num_rows == 0) { //如果在数据库中没有该bduss的相关记录 $ret['name'] = '无效'; } else { $row = $m->fetch_array($res); $ret['name'] = $row['name']; } } } return json_encode($ret); }
public function getCourse($deptAbbr, $num) { if (strpos($num, '/') !== false) { $split = split('/', $num); $courseNum = $split[0]; } else { $courseNum = $num; } for ($i = 0; $i < 3; $i++) { $courseString = $deptAbbr . str_repeat('%20', $i) . str_pad($courseNum, 4, '0', STR_PAD_LEFT); $baseUrl = 'https://webcenter.studentservices.tufts.edu/coursedesc/?courseid='; $result = htmlspecialchars_decode(curl_get($baseUrl . $courseString)); if (preg_match("/4\"\\>\\<B\\>(.+?)\\s{2,}/", $result, $matches)) { break; } } if ($matches) { return array('Num' => $num, 'Name' => formatCourseName(trim($matches[1]))); } else { return false; } }
function get_content($url) { $arrstr = array(); $arr_all = array($arrstr); //$all_str = ""; $html = curl_get($url); $dom = str_get_html($html); $container = $dom->find('.sale-item'); foreach ($container as $item) { $a = $item->find("p", 0); //$all_str = $a->plaintext . ";"; $arrstr[0] = $a->plaintext; //echo "*************" . '<br>'; $a = $item->find("p", 1); //$all_str = $all_str . $a->plaintext . ";"; $arrstr[1] = $a->plaintext; //echo "*************" . '<br>'; $a = $item->find("img", 0); //$all_str = $all_str . $a->src . ";"; $arrstr[2] = $a->src; //echo "*************" . '<br>'; $a = $item->find("p.price", 0); //$all_str = $all_str . $a->plaintext . ";"; $arrstr[3] = $a->plaintext; //echo "*************" . '<br>'; $a = $item->find("a.to-cart", 0); //$all_str = $all_str . $a->attr['product-id'] . ";"; $arrstr[4] = $a->attr['product-id']; //$all_str = $all_str . $a->plaintext . ";"; $arrstr[5] = $a->plaintext; $a = $item->find("a", 0); //$all_str = $all_str . $a->href; $arrstr[5] = $a->href; //echo $all_str . '<br>'; $arr_all[] = $arrstr; } return $arr_all; }
function feedback_compare($node_whole, $data_type) { return TRUE; global $check_feedback_url, $idc, $hostname; $args = array("node_whole" => $node_whole, "idc" => $idc, "data_type" => $data_type); $ret = curl_get($check_feedback_url, $args); if ($ret === FALSE) { echo_color("failed to check feedback on {$fd_url}", RED); return FALSE; } $feedback_res = json_decode($ret, true); $errno = $feedback_res["errno"]; if ($errno != 0) { echo_color("error happened when chech feedback, errno({$errno}), node_whole({$node_whole}), idc({$idc}))", RED); return FALSE; } echo_color("feedback success, node_whole({$node_whole}), idc({$idc}))", GREEN); return TRUE; }
function get_artist_info($artist_id) { $url = "http://music.163.com/api/artist/" . $artist_id; return curl_get($url); }
function get_shared_edit_link($fileid) { $response = curl_get(skydrive_base_url . $fileid . "/shared_edit_link?access_token=" . $this->access_token); if (@array_key_exists('error', $response)) { throw new Exception($response['error'] . " - " . $response['description']); exit; } else { return $response['link']; } }