欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

采集百度百科城市介绍

程序员文章站 2024-02-19 17:46:10
...
隐藏行号 复制代码 这是一段程序代码。
  1. include_once  'Snoopy.class.php';
  2. $word = '北京';
  3. $word = iconv('utf-8', 'gbk', $word);
  4. $url = "http://baike.baidu.com/search/word?word=".urlencode($word)."&pic=1&sug=1&enc=GBK";
  5. $url = iconv('utf-8', 'gbk', $url);
  6. $snoopy = new Snoopy();
  7. $arr = array();
  8. $snoopy->agent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11";
  9. $snoopy->setcookies('bk.doubt.tipbubble=1; undefined=show%3Dtrue; BAIDUID=3C8DBE160B442A473F00B534F2DC28EA:FG=1; bdshare_firstime=1362030797753; MAP_NEWDATA=V0; MAP_NEWDATA1=V1; BDREFER=%7Burl%3A%22http%3A//auto.baidu.com/%22%2Cword%3A%22%22%7D; BAIDULXBCB=19F69332B7BD0E7F6E5832BB5BC4B7F1AC3A33914F54038F85568856D663B7582917455BD3E27FBDB6923B0DA510DF1B201504AE9FBA9761ABE3C70DA6D3CC317663FBC33943D8527D7BD106461A334B; SSUDB=Ec4NWtsYlF5c045Q2hFTmxOVnNyanFJSlVhc1F2S29kSkVleFZpcUVFbnlOR1ZSQVFBQUFBJCQAAAAAAAAAAAEAAADF6f0MeXVoYW44MjM5Mjg4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPKnPVHypz1RO; PMS_Cache=1363068035843; BDUSS=Ec4NWtsYlF5c045Q2hFTmxOVnNyanFJSlVhc1F2S29kSkVleFZpcUVFbnlOR1ZSQVFBQUFBJCQAAAAAAAAAAAEAAADF6f0MeXVoYW44MjM5Mjg4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPKnPVHypz1RO; BDUT=4z5d3C8DBE160B442A473F00B534F2DC28EA13d1ecf54a30; MCITY=-2912%3A; IM_old=0|he9hpobl; H_PS_PSSID=1895_1444_1945_1788; Hm_lvt_55b574651fcae74b0a9f1cf9c8d7c93a=1363236133,1363236485,1363239512,1363239701; Hm_lpvt_55b574651fcae74b0a9f1cf9c8d7c93a=1363239701');
  10. $snoopy->fetch($url);
  11. echo $snoopy->results;

转载于:https://my.oschina.net/t3G1E4X/blog/113877