We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在模拟浏览器请求的时候,要注意如果URL中包含了中文字符串要进行处理,具体可以用urlencode函数来进行转换,不然模拟的请求会失败,还有模拟请求头也要尽可能一样 这个URL是可以的,因为科技已经转换为**%E7%A7%91%E6%8A%80** $url = 'http://115.28.54.40:8080/beautyideaInterface/api/v1/resources/search_res?condition=%E7%A7%91%E6%8A%80&imieId=771151417E03687F75D855F69DA18724&pageNo=10&pageSize=10'; 这个URL是不可以的,因为URL在CURL请求中带了中文会失效 $url = 'http://115.28.54.40:8080/beautyideaInterface/api/v1/resources/search_res?condition='.urlencode('科技').'&imieId=771151417E03687F75D855F69DA18724&pageNo=10&pageSize=10
$url = 'http://115.28.54.40:8080/beautyideaInterface/api/v1/resources/search_res?condition=%E7%A7%91%E6%8A%80&imieId=771151417E03687F75D855F69DA18724&pageNo=10&pageSize=10';
$url = 'http://115.28.54.40:8080/beautyideaInterface/api/v1/resources/search_res?condition='.urlencode('科技').'&imieId=771151417E03687F75D855F69DA18724&pageNo=10&pageSize=10
urlencode()
urldecode()
<?php //$url = 'http://115.28.54.40:8080/beautyideaInterface/api/v1/resources/search_res?condition=%E7%A7%91%E6%8A%80&imieId=771151417E03687F75D855F69DA18724&pageNo=10&pageSize=10'; $url = 'http://115.28.54.40:8080/beautyideaInterface/api/v1/resources/search_res?condition='.urlencode('科技').'&imieId=771151417E03687F75D855F69DA18724&pageNo=10&pageSize=10'; $ch = curl_init(); $header = 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', 'Host:115.28.54.40:8080', 'Upgrade-Insecure-Requests:1', 'User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1', ); curl_setopt($ch, CURLOPT_HTTPHEADER , $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 执行HTTP请求 curl_setopt($ch , CURLOPT_URL , $url); $res = curl_exec($ch); echo $res; ?>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在模拟浏览器请求的时候,要注意如果URL中包含了中文字符串要进行处理,具体可以用urlencode函数来进行转换,不然模拟的请求会失败,还有模拟请求头也要尽可能一样
这个URL是可以的,因为科技已经转换为**%E7%A7%91%E6%8A%80**
$url = 'http://115.28.54.40:8080/beautyideaInterface/api/v1/resources/search_res?condition=%E7%A7%91%E6%8A%80&imieId=771151417E03687F75D855F69DA18724&pageNo=10&pageSize=10';
这个URL是不可以的,因为URL在CURL请求中带了中文会失效
$url = 'http://115.28.54.40:8080/beautyideaInterface/api/v1/resources/search_res?condition='.urlencode('科技').'&imieId=771151417E03687F75D855F69DA18724&pageNo=10&pageSize=10
urlencode()
函数原理就是首先把中文字符转换为十六进制,然后在每个字符前面加一个标识符%urldecode()
函数与urlencode()函数原理相反,用于解码已编码的 URL 字符串,其原理就是把十六进制字符串转换为中文字符The text was updated successfully, but these errors were encountered: