Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.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# 如何在谷歌上搜索普通单词_C#_Visual Studio_Google Search - Fatal编程技术网

C# 如何在谷歌上搜索普通单词

C# 如何在谷歌上搜索普通单词,c#,visual-studio,google-search,C#,Visual Studio,Google Search,如何执行随机单词谷歌搜索?我知道如何使用像这样的基本网址,但我需要知道如何去谷歌和搜索狗的,它应该拿出的东西,这是可能的还是不可能的 using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace SimplicityWebBrowser { public partial class Simplicity : Form {

如何执行随机单词谷歌搜索?我知道如何使用像这样的基本网址,但我需要知道如何去谷歌和搜索狗的,它应该拿出的东西,这是可能的还是不可能的

using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SimplicityWebBrowser
{
    public partial class Simplicity : Form
    {
        public Simplicity()
        {
            InitializeComponent();
        }

        /// <summary>
        /// When click button navigate's to specific URL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Search_Click(object sender, EventArgs e)
        {
            WebBrowser.Navigate(SearchBar.Text);
        }
    }
}
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows.Forms;
命名空间SimplicityWebBrowser
{
公共部分类简单性:形式
{
公共简易性()
{
初始化组件();
}
/// 
///单击按钮时,导航到特定的URL
/// 
/// 
/// 
私有无效搜索\u单击(对象发送者,事件参数e)
{
WebBrowser.Navigate(SearchBar.Text);
}
}
}
根据您对问题的回答,您的实际问题是如何搜索用户提供的单词

您需要将正确的URL传递给您的搜索引擎(在本例中,您在评论中提到谷歌):


如果您想支持多个单词,在将其添加到URL之前,您需要将任何空格替换为
+
,这样,如果用户在文本框中键入
大狗
,您就可以将
大狗
添加到搜索URL。(如何替换空格将是一个单独的问题,我敢肯定我以前在这里被问过。)

您是否尝试在自己的浏览器中搜索并查看它发送给谷歌的URL(在位置栏中)?在浏览器的搜索功能中搜索任何内容;当你在谷歌上列出搜索结果时,看看位置栏,看看那里有什么。我没有什么。我不知道你怎么做。我不知道怎样才能更清楚。进入你的网络浏览器(Firefox/InternetExplorer/Chrome/Safari/随便什么)。在搜索区域中键入
dogs
,然后单击搜索按钮。查看位置栏(您键入的位置
http://google.com
去谷歌)看看有什么。当您执行
WebBrowser时,您需要在代码中执行相同的操作。在您现在拥有
SearchBar.Text的部分导航
。(它将类似于
https://www.google.com/search?q=dogs
但这使它成为一个特定的词而不是一个随机词,不是吗?例如?
WebBrowser.Navigate("https://www.google.com/search?q=" + SearchBar.Text);