php curl抓取淘宝页面返回1没有返回数据,header头部已经设置和淘宝一样
<?php/***根据地址抓取淘宝页面html代码*@paramtype$url地址*@returnboolean*/functiongetTaoBaoHtml($url...
<?php
/**
* 根据地址抓取淘宝页面html代码
* @param type $url 地址
* @return boolean
*/
function getTaoBaoHtml($url) {
if (empty($url)) {
return false;
}
$ch = curl_init();
// 设置 url
curl_setopt($ch, CURLOPT_URL, $url);
// 设置浏览器的特定header
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Accept: {text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8}",
"Accept-Encoding: {gzip, deflate, sdch}",
"Accept-Language: {zh-CN,zh;q=0.8}",
"Cache-Control: {max-age=0}",
"Connection: {keep-alive}",
"Cookie: {thw=cn; cna=374BDmlIvy8CAd4jkqP9aMuc; v=0; _tb_token_=3450e7655e57; cookie2=1c8a881b13e334d2bdaae84a684fd804; t=a1b5026ddd1655d666790129b4b0a3fa; uc1=cookie14=UoW0FJYgx%2BjK%2BA%3D%3D; mt=ci%3D-1_0; l=Avv7hq3pfDfaWEO23egSCqNZC9Fl-Q9T; isg=611E5D64C8E2FFE9C886563F304446C1}",
"User-Agent: {Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36}",
));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$html = curl_exec($ch);
print_r($html);
}
getTaoBaoHtml($_GET['url']); 展开
/**
* 根据地址抓取淘宝页面html代码
* @param type $url 地址
* @return boolean
*/
function getTaoBaoHtml($url) {
if (empty($url)) {
return false;
}
$ch = curl_init();
// 设置 url
curl_setopt($ch, CURLOPT_URL, $url);
// 设置浏览器的特定header
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Accept: {text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8}",
"Accept-Encoding: {gzip, deflate, sdch}",
"Accept-Language: {zh-CN,zh;q=0.8}",
"Cache-Control: {max-age=0}",
"Connection: {keep-alive}",
"Cookie: {thw=cn; cna=374BDmlIvy8CAd4jkqP9aMuc; v=0; _tb_token_=3450e7655e57; cookie2=1c8a881b13e334d2bdaae84a684fd804; t=a1b5026ddd1655d666790129b4b0a3fa; uc1=cookie14=UoW0FJYgx%2BjK%2BA%3D%3D; mt=ci%3D-1_0; l=Avv7hq3pfDfaWEO23egSCqNZC9Fl-Q9T; isg=611E5D64C8E2FFE9C886563F304446C1}",
"User-Agent: {Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36}",
));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$html = curl_exec($ch);
print_r($html);
}
getTaoBaoHtml($_GET['url']); 展开
1个回答
2015-07-11
展开全部
SP_CONFIGURE 'SHOW ADVANCED OPTIONS',1
RECONFIGURE
EXEC SP_CONFIGURE 'Ad Hoc Distributed Queries',1
RECONFIGURE
插入的代码:
INSERT INTO dbo.Resources(ResourcesUrl,ResourcesLink,ResourcesText) SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;HDR=YES;Database=F:\Book1.xls', [sheet1$])
RECONFIGURE
EXEC SP_CONFIGURE 'Ad Hoc Distributed Queries',1
RECONFIGURE
插入的代码:
INSERT INTO dbo.Resources(ResourcesUrl,ResourcesLink,ResourcesText) SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;HDR=YES;Database=F:\Book1.xls', [sheet1$])
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询