生活随笔
收集整理的這篇文章主要介紹了
file_get_contents()采集不到原因
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
file_get_contents()
服務器必須開啟:allow_url_fopen = On
?
?
<?php?????if(!ini_get('display_errors')){?????????ini_set('display_errors','On');?????}?????error_reporting(E_ALL?&?~E_NOTICE);??????????$con008=file_get_contents("http://www.baidu.com/");?????$preg008='#<dt><a?href="(.*)"??title="(.*)">(.*)</a></dt>#iUs';?????preg_match_all($preg008,$con008,$arr008);?????$conn002=mysql_connect("localhost:6305","xxxx","xxxx")?or?die?("連接數據庫服務器失敗");?????mysql_select_db("xxxx",$conn002);?????mysql_query("set?names?'UTF-8'");?????foreach($arr008[2]?as?$id=>$v){??????????????echo?'<pre?/>';?????????print_r($v);?????????echo?'<pre?/>';??????????????$sql10="INSERT?INTO?`caiji_bkhot`?(`id`,?`title`,?`url`)?VALUES?(NULL?,?'".iconv("UTF-8",?"GBK",?$v)."'?,?'".iconv("UTF-8",?"GBK",?$arr008[1][$id])."')";?????????mysql_query($sql10);?????}?????$last_id008=?mysql_insert_id();?????$sql11="delete?from?`caiji_bkhot`?where?id?<=?$last_id008?-?6";?????mysql_query($sql11);??>? ?
轉載于:https://blog.51cto.com/xuqin/963386
總結
以上是生活随笔為你收集整理的file_get_contents()采集不到原因的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。