C# 关于获取百度搜索结果的问题

.Net技术 码拜 8年前 (2016-02-26) 1290次浏览
 string url = "https://www.baidu.com/s?wd=北京故宫";
            System.Net.HttpWebRequest req;
            HttpWebResponse response;
            Stream stream;
            req = (HttpWebRequest)WebRequest.Create(url);
            response = (HttpWebResponse)req.GetResponse();

获取的结果是:
<html>
<head>
<script>
location.replace(location.href.replace(“https://”,”http://”));
</script>
</head>
<body>
<noscript><meta http-equiv=”refresh” content=”0;url=http://www.baidu.com/”></noscript>
</body>
</html>

解决方案

5

你这里的东西看不出什么来
返回的结果明显是访问错误返回的结果 让浏览器跳百度首页去
而贴出来的代码中 url 又是正确的。

35

你的 https 应该改为 http。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C# 关于获取百度搜索结果的问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)