欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php中Snoopy類用法實(shí)例

 更新時(shí)間:2015年06月19日 16:21:36   作者:不吃皮蛋  
這篇文章主要介紹了php中Snoopy類用法,實(shí)例分析了使用Snoopy類實(shí)現(xiàn)頁(yè)面抓取的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了php中Snoopy類用法。分享給大家供大家參考。具體分析如下:

這里演示了php中如何通過Snoopy抓取網(wǎng)頁(yè)信息

snoopy類的下載地址:http://sourceforge.net/projects/snoopy/

/*
You need the snoopy.class.php from 
http://snoopy.sourceforge.net/
*/
include("snoopy.class.php");
$snoopy = new Snoopy;
// need an proxy?:
//$snoopy->proxy_host = "my.proxy.host";
//$snoopy->proxy_port = "8080";
// set browser and referer:
$snoopy->agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$snoopy->referer = "http://www.jonasjohn.de/";
// set some cookies:
$snoopy->cookies["SessionID"] = '238472834723489';
$snoopy->cookies["favoriteColor"] = "blue";
// set an raw-header:
$snoopy->rawheaders["Pragma"] = "no-cache";
// set some internal variables:
$snoopy->maxredirs = 2;
$snoopy->offsiteok = false;
$snoopy->expandlinks = false;
// set username and password (optional)
//$snoopy->user = "joe";
//$snoopy->pass = "bloe";
// fetch the text of the website www.google.com:
if($snoopy->fetchtext("http://www.google.com")){ 
  // other methods: fetch, fetchform, fetchlinks, submittext and submitlinks
  // response code:
  print "response code: ".$snoopy->response_code."<br/>\n";
  // print the headers:
  print "<b>Headers:</b><br/>";
  while(list($key,$val) = each($snoopy->headers)){
    print $key.": ".$val."<br/>\n";
  }
  print "<br/>\n";
 
  // print the texts of the website:
  print "<pre>".htmlspecialchars($snoopy->results)."</pre>\n";
}
else {
  print "Snoopy: error while fetching document: ".$snoopy->error."\n";
}

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • PHP mkdir創(chuàng)建文件夾實(shí)現(xiàn)方法解析

    PHP mkdir創(chuàng)建文件夾實(shí)現(xiàn)方法解析

    這篇文章主要介紹了PHP mkdir創(chuàng)建文件夾實(shí)現(xiàn)方法解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-11-11
  • php array_intersect()函數(shù)使用代碼

    php array_intersect()函數(shù)使用代碼

    array_intersect() 返回一個(gè)數(shù)組,該數(shù)組包含了所有在 array1 中也同時(shí)出現(xiàn)在所有其它參數(shù)數(shù)組中的值。注意鍵名保留不變。
    2009-01-01
  • php中將網(wǎng)址轉(zhuǎn)換為超鏈接的函數(shù)

    php中將網(wǎng)址轉(zhuǎn)換為超鏈接的函數(shù)

    php中將網(wǎng)址轉(zhuǎn)換為超鏈接的函數(shù),需要的朋友可以參考下。
    2011-09-09
  • PHP數(shù)組基本用法與知識(shí)點(diǎn)總結(jié)

    PHP數(shù)組基本用法與知識(shí)點(diǎn)總結(jié)

    這篇文章主要介紹了PHP數(shù)組基本用法與知識(shí)點(diǎn),總結(jié)整理了PHP數(shù)組基本概念、用法、定義、訪問、刪除等相關(guān)操作技巧,需要的朋友可以參考下
    2020-06-06
  • PHP門面模式實(shí)現(xiàn)簡(jiǎn)單的郵件發(fā)送示例

    PHP門面模式實(shí)現(xiàn)簡(jiǎn)單的郵件發(fā)送示例

    這篇文章主要為大家介紹了PHP門面模式實(shí)現(xiàn)簡(jiǎn)單的郵件發(fā)送示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • PHP Document 代碼注釋規(guī)范

    PHP Document 代碼注釋規(guī)范

    PHPDocumentor是一個(gè)用PHP寫的工具,對(duì)于有規(guī)范注釋的php程序,它能夠快速生成具有相互參照,索引等功能的API文檔。老的版本是 phpdoc。
    2009-04-04
  • php array_map array_multisort 高效處理多維數(shù)組排序

    php array_map array_multisort 高效處理多維數(shù)組排序

    用array_map和array_multisort高效處理多維數(shù)組排序的實(shí)現(xiàn)代碼。
    2009-06-06
  • 允許phpmyadmin空密碼登錄的配置方法

    允許phpmyadmin空密碼登錄的配置方法

    在Mysql修改root密碼的命令及方法一文中,我提到了使用phpmyadmin修改Mysql的root密碼的方法,但是當(dāng)你將phpmyadmin登錄密碼設(shè)置為空密碼時(shí),盡管你通過Mysql命令行方式可以以空密碼進(jìn)入Mysql,但是當(dāng)你重新以空密碼登錄phpmyadmin時(shí)卻無法登陸
    2011-05-05
  • PHP也能干大事之PHP中的編碼解碼詳解

    PHP也能干大事之PHP中的編碼解碼詳解

    這篇文章主要介紹了PHP也能干大事之PHP中的編碼解碼詳解,本文講解了ASCII編解碼、URL編解碼、Base64編解碼、HTML實(shí)體編解碼、二進(jìn)制、八進(jìn)制、十進(jìn)制、十六進(jìn)制相互轉(zhuǎn)換等內(nèi)容,需要的朋友可以參考下
    2015-04-04
  • PHP實(shí)現(xiàn)接收二進(jìn)制流轉(zhuǎn)換成圖片的方法

    PHP實(shí)現(xiàn)接收二進(jìn)制流轉(zhuǎn)換成圖片的方法

    這篇文章主要介紹了PHP實(shí)現(xiàn)接收二進(jìn)制流轉(zhuǎn)換成圖片的方法,結(jié)合實(shí)例形式分析了php文件、目錄及圖形操作的相關(guān)技巧,需要的朋友可以參考下
    2017-01-01

最新評(píng)論