修改的curl命令和原始curl命令执行之后返回的结果完全不一样

以课上老师讲的百度搜索“霍格沃茨测试学院”为例:
复制原始curl命令如下:

curl 'https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=2&tn=baiduhome_pg&wd=%E9%9C%8D%E6%A0%BC%E6%B2%83%E8%8C%A8%E6%B5%8B%E8%AF%95%E5%AD%A6%E9%99%A2&rsv_spt=1&oq=%25E7%2599%25BE%25E5%25BA%25A6&rsv_pq=988dbac1000e0523&rsv_t=232fNw1xXRjNyZBuHiP%2FETqSeQJgWJnpSwIYBbRP6WkARyMfvwllHY6L84O5tTTVjAvh&rqlang=cn&rsv_enter=1&rsv_dl=tb&rsv_sug3=22&rsv_sug1=8&rsv_sug7=100&rsv_sug2=0&inputT=4890&rsv_sug4=4891' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36' -H 'Sec-Fetch-User: ?1' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-Mode: navigate' -H 'Referer: https://www.baidu.com/s?wd=%E9%9C%8D%E6%A0%BC%E6%B2%83%E5%85%B9%E6%B5%8B%E8%AF%95%E5%AD%A6%E9%99%A2&rsv_spt=1&rsv_iqid=0xcb2ca4f7000013cb&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=78000241_25_hao_pg&rsv_enter=1&rsv_dl=tb&rsv_sug3=22&rsv_sug1=7&rsv_sug7=100&rsv_t=de8auUCssHD5KIHV%2F7rv29RVopmfhqTL7yyvvQ7OGGwf6Qi%2BUJ2GD4LOXifqEAJrgDYr%2F0tcTseE&rsv_sug2=0&inputT=5784&rsv_sug4=5785' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Cookie: PSTM=1575866970; BIDUPSID=0494C203F3CFD66BA4E925BD48BE8901; BAIDUID=6A5A10119B7BABE4D17C533B46DEF14B:FG=1; BD_UPN=12314753; ispeed_lsm=2; BDUSS=0JXY1RsRXdzRDJQRkJNQWtzS3JsZm9Td1J0YVBUaEkydkhwb2s4SHNEdDNrYVplRVFBQUFBJCQAAAAAAAAAAAEAAAC2GP4KeGlhbzIzODMwNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHcEf153BH9eN; BDRCVFR[JWsSqdXVLz3]=o5h-9ZptSamXZ7Bmy4bQhP8; BD_HOME=1; delPer=0; BD_CK_SAM=1; PSINO=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BDRCVFR[feWj1Vr5u3D]=2tsMiS_WGPYfjT3nj0snWfkg1cdgv99; H_PS_PSSID=1444_31170_21093_30826_31187_30905_30824_31086_26350; H_PS_645EC=c5a7YOjOitA3HRPtwBvRMvlbCB%2FkqkDmSaSaW1lEZmaBjeHtnMKFLSAC3nGpNSxHTk9%2F; BDSVRTM=108' --compressed

在centos7下执行的结果如下:

按课上老师所讲的将原始命令修改如下:

curl -G url 'https://www.baidu.com' --data-urlencode 'wd:霍格沃茨测试学院' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36' -H 'Sec-Fetch-User: ?1' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-Mode: navigate' -H 'Referer: https://www.baidu.com/s?wd=%E9%9C%8D%E6%A0%BC%E6%B2%83%E5%85%B9%E6%B5%8B%E8%AF%95%E5%AD%A6%E9%99%A2&rsv_spt=1&rsv_iqid=0xcb2ca4f7000013cb&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=78000241_25_hao_pg&rsv_enter=1&rsv_dl=tb&rsv_sug3=22&rsv_sug1=7&rsv_sug7=100&rsv_t=de8auUCssHD5KIHV%2F7rv29RVopmfhqTL7yyvvQ7OGGwf6Qi%2BUJ2GD4LOXifqEAJrgDYr%2F0tcTseE&rsv_sug2=0&inputT=5784&rsv_sug4=5785' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Cookie: PSTM=1575866970; BIDUPSID=0494C203F3CFD66BA4E925BD48BE8901; BAIDUID=6A5A10119B7BABE4D17C533B46DEF14B:FG=1; BD_UPN=12314753; ispeed_lsm=2; BDUSS=0JXY1RsRXdzRDJQRkJNQWtzS3JsZm9Td1J0YVBUaEkydkhwb2s4SHNEdDNrYVplRVFBQUFBJCQAAAAAAAAAAAEAAAC2GP4KeGlhbzIzODMwNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHcEf153BH9eN; BDRCVFR[JWsSqdXVLz3]=o5h-9ZptSamXZ7Bmy4bQhP8; BD_HOME=1; delPer=0; BD_CK_SAM=1; PSINO=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BDRCVFR[feWj1Vr5u3D]=2tsMiS_WGPYfjT3nj0snWfkg1cdgv99; H_PS_PSSID=1444_31170_21093_30826_31187_30905_30824_31086_26350; H_PS_645EC=c5a7YOjOitA3HRPtwBvRMvlbCB%2FkqkDmSaSaW1lEZmaBjeHtnMKFLSAC3nGpNSxHTk9%2F; BDSVRTM=108' --compressed

centos7下执行结果如下:

如上所示,这两个命令返回的结果完全不一样,这是为什么呢?

wd=霍格沃兹这样,不是wd:霍格沃兹。当时我在课上说明这一点了

1 Like

改成’wd=霍格沃茨测试学院’也是一样

问题已经解决,修改后命令如下就可以正常返回了

curl -G url 'https://www.baidu.com/s' --data-urlencode 'wd=霍格沃茨测试学院' .........

只需要在原网址后边加上 ‘/s’

关闭