Php使用curl模拟浏览器采集网页
作者:admin 日期:2012-06-16
Php使用curl模拟浏览器采集网页
PHP代码
- <?php
- set_time_limit(0);
- function _rand() {
- $length=26;
- $chars = "0123456789abcdefghijklmnopqrstuvwxyz";
- $max = strlen($chars) - 1;
- mt_srand((double)microtime() * 1000000);
- $string = '';
- for($i = 0; $i < $length; $i++) {
- $string .= $chars[mt_rand(0, $max)];
- }
- return $string;
- }
- $HTTP_SESSION=_rand();
- $HTTP_SESSION;
- $HTTP_Server="search.china.alibaba.com";
- $HTTP_URL="/company/k-%CB%AE%CB%AE%CB%AE_n-y.html";
- $ch = curl_init();
- curl_setopt ($ch,CURLOPT_URL,"http://".$HTTP_Server.$HTTP_URL);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- 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)");
- $res = curl_exec($ch);
- curl_close ($ch);
- print_r($res);
- ?>
上一篇: Asp判断字符串中是否包含连续的重复字符
下一篇: VB 文件未找到: 'C:\WINDOWS\system32\ieframe.dll\1'
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: php curl
相关日志:
下一篇: VB 文件未找到: 'C:\WINDOWS\system32\ieframe.dll\1'
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: php curl
相关日志:
评论: 0 | 引用: 0 | 查看次数: 4767
发表评论
广告位