php curl 如何抓取淘宝商品页面?求大神回复。。感觉超难。

启点mx 2014-01-28 04:07:48
这是我写的curl抓取代码,抓取天猫商品也有用。但淘宝商品页却抓不了。

<?php
$url = "http://detail.tmall.com/item.htm?id=2315770603";
//$url = "http://www.donlimmall.com/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$ret = curl_exec($ch);
curl_close($ch);
echo $ret;
?>

加了CURLOPT_FOLLOWLOCATION也没用。。求大神指导
...全文
264 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
启点mx 2014-01-29
  • 打赏
  • 举报
回复
引用 3 楼 changjay 的回复:
header("Content-type: text/html; charset=GB2312"); $url = "http://detail.tmall.com/item.htm?id=2315770603"; //$url = "http://www.donlimmall.com/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie00.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie00.txt"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); $ret = curl_exec($ch); curl_close($ch); echo $ret;
sorry 我发错了。。。这个是天猫的链接。。 哥们 淘宝的怎么抓啊 http://item.taobao.com/item.htm?id=16396503658
  • 打赏
  • 举报
回复
header("Content-type: text/html; charset=GB2312"); $url = "http://detail.tmall.com/item.htm?id=2315770603"; //$url = "http://www.donlimmall.com/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie00.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie00.txt"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); $ret = curl_exec($ch); curl_close($ch); echo $ret;
启点mx 2014-01-28
  • 打赏
  • 举报
回复
引用 1 楼 iasky 的回复:
看看header中的东西,一般是没有模拟好。
求大神帮忙
iasky 2014-01-28
  • 打赏
  • 举报
回复
看看header中的东西,一般是没有模拟好。

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧