cURL与基于代理的URL

时间:2015-04-11 06:56:28

标签: php curl proxy

我要使用import.io api访问此网站http://www.autonet.ca/的内容,它基于加拿大。它可以通过浏览器代理访问,但我可以使用cURL访问它,但它返回null。

$cc_se_page_url_autonet = "https://api.import.io/store/data/dd8eed56-4d41-4f43-aed6-ef8e7b3e9fc9/_query?input/webpage/url=http://www.autonet.ca/used-vehicles/montreal-qc/2010+2011+2012%20-honda-accord?price=0-5000&sortby=distance+asc&kmfrom=0&kmto=13000&_user=8df097bf-2f5d-4509-b13e-299d05bad826&_apikey=8df097bf-2f5d-4509-b13e-299d05bad826%3AH76otVMlVTG2KIW9fCZjWPtf4KzWFmlNBzbD2WIy9qOKSwIPgGxmUFVmTV9dDrORwcTtMBS1zZVLXSdEd9yfPQ%3D%3D";

//  Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Set the url
#curl_setopt($ch, CURLOPT_URL, $cc_se_page_extractor_url_kijiji);
curl_setopt($ch, CURLOPT_URL, $cc_se_page_url_autonet);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);

// Will dump a beauty json :3
var_dump(json_decode($result, true));

如果您在浏览器中复制/粘贴$ cc_se_page_url_autonet网址,您会看到joson结果,但cURL不会返回输出?任何与代理一起访问cURL的解决方案?

浏览器中的输出是:

{  
   "offset":0,
   "results":[  

   ],
   "cookies":[  
      "PHPSESSID=\"b5a335b54dd408f355726cd290c4d2ce\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_lastVisitedPage=\"%2Fused-vehicles%2Fmontreal-qc%2F2010%25202011%25202012%2520-honda-accord%3Fprice%3D0-5000\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_language=\"en\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_cityPostalCode=\"Montreal\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_userCity=\"Montreal%2C+QC\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_userCityPostalCode=\"Montreal\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_userCityRegion=\"6\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "BIGipServeredition.autonet.ca_pool80=\"3653435146.20480.0000\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\""
   ],
   "connectorVersionGuid":"0603c6cf-eff5-46e2-b018-ad0bce333c5f",
   "connectorGuid":"dd8eed56-4d41-4f43-aed6-ef8e7b3e9fc9",
   "pageUrl":"http://www.autonet.ca/used-vehicles/montreal-qc/2010%202011%202012%20-honda-accord?price=0-5000",
   "outputProperties":[  
      {  
         "name":"url",
         "type":"STRING"
      }
   ]
}

0 个答案:

没有答案