Re: Snoopy功能强大的模拟浏览器方法的PHP类

添加时间:17-06-30 所属分类:PHP工具与代码
  比较完整的示例:

[code]/**
* 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 htmlspecialchars($snoopy->results)."n";
}else{
print "Snoopy: error while fetching document: ".$snoopy->error."n";
}[/code]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

前篇:退休教师夫妇为贫困孩子免费补课23年 还自费... 后篇:Snoopy 用来模仿web浏览器的功能,它能完成...
发表我的评论


推荐文章   2017索尼影赛儿童生活照引人关注   按摩穴位就可以缓解心绞痛   英国建造婴儿专属游泳池 宝贝水中秀泳姿...   女科学家生存实录:记不得上次逛街是什...   俄4岁小女孩零下34度徒步8公里救外婆,...
随机文章   PHP获取Cookie模拟登录   PHP curl函数模拟爬虫(操作cookie刷贴实...   php curl函数模拟浏览器抓取网站信息   PHP使用curl模拟用户登陆   MYSQL查询优化
广告

其他推荐

因为本站所有内容均转载自其它媒体,本意为公众提供免费服务,但并不代表本网赞同其观点,也不能对其真实性验证负责,如稿件版权单位或个人不想在本网发布,请与我联系,本人会立即将其撤除,谢谢.联系方式:atseashawk@163.com QQ:99289555