本文介绍了我正在开发一个元搜索引擎(元问答系统)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,问候
我正在用C#开发元搜索引擎(元问答系统).
我是初学者.

我系统中的问题将自动在主要搜索引擎中发布,从每个搜索引擎中至少获取10个结果并在我的系统中排名.有人可以用C#代码帮助我吗?我尝试了很多方法.

Hi Everyone, Greetings
I am developing a Meta Search Engine (Meta Question Answering System ) in C# ...
I am a beginner.

The question from my system will automatically get posted in main search engines, n minimum 10 results will be taken from each search engine and ranked in my system. Can anybody please help me with C# code for doing this please. I tried a lot cudnt do it.

推荐答案



using System.Net;
...
string HttpPost (string uri, string parameters)
{
    // parameters: name1=value1&name2=value2
    WebRequest webRequest = WebRequest.Create (uri);
    //string ProxyString =
    // System.Configuration.ConfigurationManager.AppSettings
    // [GetConfigKey("proxy")];
    //webRequest.Proxy = new WebProxy (ProxyString, true);
    //Commenting out above required change to App.Config
    webRequest.ContentType = "application/x-www-form-urlencoded";
    webRequest.Method = "POST";
    byte[] bytes = Encoding.ASCII.GetBytes (parameters);
    Stream os = null;
    try
    { // send the Post
        webRequest.ContentLength = bytes.Length; //Count bytes to send
        os = webRequest.GetRequestStream();
        os.Write (bytes, 0, bytes.Length); //Send it
    }
    catch (WebException ex)
    {
        MessageBox.Show ( ex.Message, "HttpPost: Request error",
        MessageBoxButtons.OK, MessageBoxIcon.Error );
    }
    finally
    {
        if (os != null)
        {
            os.Close();
        }
    }

    try
    { // get the response
        WebResponse webResponse = webRequest.GetResponse();
        if (webResponse == null)
        { return null; }
        StreamReader sr = new StreamReader(webResponse.GetResponseStream());
        return sr.ReadToEnd ().Trim ();
    }
    catch (WebException ex)
    {
        MessageBox.Show ( ex.Message, "HttpPost: Response error",
        MessageBoxButtons.OK, MessageBoxIcon.Error );
    }
    return null;
} // end HttpPost



但这仍然不能解决问题:(



but this still doesnt solve the problem :(


这篇关于我正在开发一个元搜索引擎(元问答系统)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 03:38