Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用C#程序进行Web搜索_C#_Web Crawler - Fatal编程技术网

使用C#程序进行Web搜索

使用C#程序进行Web搜索,c#,web-crawler,C#,Web Crawler,我正在尝试从C#应用程序中进行网络搜索。我当前使用的代码出现错误 WebRequest http = HttpWebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)http.GetResponse(); //error occurs here 我不断得到“无法解析远程名称:'search.yahooapi.com'” 以下是url参数的代码: StringBuilder url = new StringBuil

我正在尝试从C#应用程序中进行网络搜索。我当前使用的代码出现错误

WebRequest http = HttpWebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)http.GetResponse(); //error occurs here
我不断得到“无法解析远程名称:'search.yahooapi.com'”

以下是url参数的代码:

 StringBuilder url = new StringBuilder();
        url.Append("http://search.yahooapis.com/WebSearchService/V1/webSearch?");
        url.Append("appid=YahooDemo&results=100&query=");
        url.Append(HttpUtility.UrlEncode(searchFor));

我认为问题在于,我需要一个来自Yahoo的API密钥来代替上面代码中的“YahooDemo”。我访问并获得了一个应用程序ID,但当我输入它时,它仍然不起作用?我想问题是我不知道在Yahoo项目中为应用程序URL和回调域添加什么-我甚至不知道这意味着什么?我很乐意使用其他供应商,如谷歌或必应,如果这使它更容易。但我对C#还不熟悉,所以我真的需要详细但简单的解释来理解我需要做什么。我有点迷路了。最后,我基本上只想从我的C#程序中进行一次网络搜索,以查找关键词,因此,如果它们更容易做到这一点,我完全赞成。有什么建议吗

请使用不带查询参数的简单Url进行检查。。看看这是否成功。。然后,可以使用简单的URL生成查询字符串。我已经检查过了。简单的URL是有效的,你的意思是
search.yahooapi.com
?因为在我看来,这个错误很像是一个简单的DNS查找失败。另外,请尝试将@放在类似字符串的url之前。Append(@”)@kishoreVM-你不必这样做。他使用的字符不需要在url中转义。