Access to this address through nodejs or php is intercepted by Alibaba Cloud, but json data can be returned by visiting this address directly in the browser, How can I access the correct return value of this link in nodejs or php?
https://mall.xsyxsc.com/user/product/indexWindows
Direct access on the browser will return the following data:
{"rspCode":"illegalArgumentError","rspDesc":"indexWindows.areaId: 区域id不能为空, indexWindows.openBrandHouse: 是否开通品牌馆不能为空, indexWindows.storeId: 门店id不能为空","data":null}
Use nodejs https or php curl, the following prompt will be returned:
很抱歉,由于您访问的URL有可能对网站造成安全威胁,您的访问被阻断。 您的请求ID是: 2f6a1f9316055959054642583e43d3
Below is an example of my request with php:
<?php
function getRequest($url){
$headerArray = [
'Host'=>'mall.xsyxsc.com',
'User-Agent'=>'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0',
'Accept'=>'*/*',
'Accept-Language'=>'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding'=>'gzip, deflate',
'Cache-Control'=>'max-age=0'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headerArray);
$output = curl_exec($ch);
curl_close($ch);
//将返回的json对象解码成数组对象并返回
//$output = json_decode($output,true);
return $output;
}
$res = getRequest('https://mall.xsyxsc.com/user/product/indexWindows');
// $res = getRequest('https://www.baidu.com/');
exit($res);