PHP curl模拟浏览器采集阿里巴巴的实现代码

2019/6/30 15:25:11

本文主要是介绍PHP curl模拟浏览器采集阿里巴巴的实现代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

没有不可能只有不去做,哈哈
复制代码 代码如下:

<?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);
?>


这篇关于PHP curl模拟浏览器采集阿里巴巴的实现代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程