Discuz教程网

PHP 模拟浏览器 CURL 采集阿里巴巴

[复制链接]
authicon 星火燎原 发表于 2011-5-18 10:56:50 | 显示全部楼层 |阅读模式
都说阿里巴巴有不能采集和防采集的神话,今天就用张老师讲的Curl采集写了一个模拟浏览器的代码。没有不可能只有不去做,哈哈

  1. <?php
  2. set_time_limit(0);
  3. function _rand() {
  4. $length=26;
  5. $chars = "0123456789abcdefghijklmnopqrstuvwxyz";
  6. $max = strlen($chars) - 1;
  7. mt_srand((double)microtime() * 1000000);
  8. $string = '';
  9. for($i = 0; $i < $length; $i++) {
  10. $string .= $chars[mt_rand(0, $max)];
  11. }
  12. return $string;
  13. }
  14. $HTTP_SESSION=_rand();
  15. $HTTP_SESSION;
  16. $HTTP_Server="search.china.alibaba.com";
  17. $HTTP_URL="/company/k-%CB%AE%CB%AE%CB%AE_n-y.html";
  18. $ch = curl_init();
  19. curl_setopt ($ch,CURLOPT_URL,"http://".$HTTP_Server.$HTTP_URL);
  20. curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  21. curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
  22. $res = curl_exec($ch);
  23. curl_close ($ch);
  24. print_r($res);

  25. ?>
复制代码




上一篇:php简单对象与数组的转换函数代码(php多层数组和对象的转换)
下一篇:php 生成迅雷快车旋风链接
authicon 卡卡猫 发表于 2011-5-18 19:29:49 | 显示全部楼层
哈哈  收了你
authicon kikiya11 发表于 2011-5-18 23:29:54 | 显示全部楼层
很好 很强大。。谢谢分享
authicon 婷婷爱牛牛 发表于 2011-5-19 04:29:40 | 显示全部楼层
支持楼主,顶一下
authicon YY大兔子 发表于 2011-5-19 05:29:53 | 显示全部楼层
继续来索要
authicon ningbear 发表于 2011-5-19 11:29:57 | 显示全部楼层
哈哈  收了你
authicon lightning123 发表于 2011-5-19 18:30:52 | 显示全部楼层
支持!好东西,拿走了!
authicon TRACYFLYING 发表于 2011-5-19 23:29:39 | 显示全部楼层
很好 很强大。。谢谢分享
authicon 82xiaochong911 发表于 2011-5-20 00:29:52 | 显示全部楼层
我回不回呢 考虑再三 还是不回了吧 ^_^
authicon 卡卡猫 发表于 2011-5-20 01:29:38 | 显示全部楼层
很好 很强大。。谢谢分享
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-3 05:49

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表