日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

curl抓取信息

發(fā)布時間:2024/4/17 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 curl抓取信息 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
<?php$hotel = new curl(false,0);$str = $hotel -> post("http://www.todayinns.com/login.php?do=login",array("Referer"=>"","username"=>"18612690317","password"=>"2010"))->execute();echo $hotel -> get("http://www.todayinns.com/my_jf.php")->execute();;/*** 一個基礎(chǔ)的CURL類** @author Smala*/class curl{public $ch;public $cookie = '/cookie'; public $rstr; public $info; public function __construct($ssl=true,$cookieName="tmp.cookie"){$this -> cookie = dirname(__FILE__)."/".$cookieName;$this -> ch = curl_init();curl_setopt($this -> ch ,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36');//設(shè)置用戶代理curl_setopt($this -> ch,CURLOPT_COOKIEJAR,$this -> cookie); curl_setopt($this -> ch,CURLOPT_COOKIEFILE,$this -> cookie); if($ssl){curl_setopt($this -> ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($this -> ch, CURLOPT_SSL_VERIFYHOST, false);}curl_setopt($this -> ch,CURLOPT_RETURNTRANSFER,1);}public function set($opt){foreach($opt as $key => $value)curl_setopt($this -> ch,$key,$value);return $this;}public function get($url,$data=array()){$queryString = http_build_query($data);if(!empty($queryString)){$url.= '?'.$queryString;}curl_setopt($this -> ch,CURLOPT_URL,$url);return $this;}public function setHeader($data=array()){curl_setopt($this -> ch,CURLOPT_HTTPHEADER,$data);return $this;}public function post($url,$data = array()){$post = '';foreach($data as $key=>$value){$post .= $key.'='.$value."&";}$post = trim($post,'&');curl_setopt($this -> ch,CURLOPT_URL,$url);curl_setopt($this -> ch,CURLOPT_POST,1); curl_setopt($this -> ch,CURLOPT_POSTFIELDS,$post); return $this;}public function execute($close=true){$this -> rstr = curl_exec($this -> ch);$this -> info = curl_getinfo($this -> ch);if($close){// curl_close($this -> ch); }return $this -> rstr;}public function close(){curl_close($this -> ch);}} $hotel = new curl(false,0); $str = $hotel -> post("http://www.todayinns.com/login.php?do=login",array("Referer"=>"","username"=>$_COOKIE['the_tel'],"password"=>$_COOKIE['password']))->execute(); $arrs = $hotel -> get("http://www.todayinns.com/my_ticket.php")->execute(); preg_match_all('/<dd class="c">(.*?)<\/dd>/is',$arrs,$tmp); preg_match_all( '/<tr[^>]*([\s\S]*?)<\/tr>/i', $tmp[1][0], $arr ); preg_match_all( '/<td>(.*?)<\/td>/i', $arr[1][1], $volume );

?

轉(zhuǎn)載于:https://www.cnblogs.com/phpfensi/p/3910783.html

總結(jié)

以上是生活随笔為你收集整理的curl抓取信息的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。