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# 如何浏览网页(输入、选择、按钮提交)_C#_Select_Button_Input_Httpclient - Fatal编程技术网

C# 如何浏览网页(输入、选择、按钮提交)

C# 如何浏览网页(输入、选择、按钮提交),c#,select,button,input,httpclient,C#,Select,Button,Input,Httpclient,我正在尝试自动执行页面搜索结果,并使用C#将结果放入JSON或CSV文件中 大纲是: 转到网页 更改日期(HTML输入修改) 选择城市(HTML多选修改) 单击submit按钮(名为submit的HTML按钮) 得到结果 单击“下一步”以获取下一页结果 我可以获得初始页面(步骤1),但我不知道有哪些实用程序可以更新HTML并单击按钮 源代码如下所示: async static void Function1() { using (HttpClient client = new HttpCl

我正在尝试自动执行页面搜索结果,并使用C#将结果放入JSON或CSV文件中

大纲是:

  • 转到网页
  • 更改日期(HTML输入修改)
  • 选择城市(HTML多选修改)
  • 单击submit按钮(名为submit的HTML按钮)
  • 得到结果
  • 单击“下一步”以获取下一页结果
  • 我可以获得初始页面(步骤1),但我不知道有哪些实用程序可以更新HTML并单击按钮

    源代码如下所示:

    async static void Function1()
    {
        using (HttpClient client = new HttpClient())
        {
        using (HttpResponseMessage response = await client.GetAsync("http://bla.com/searches/index"))
        {
            using (HttpContent content = response.Content)
            {
            string mycontent = await content.ReadAsStringAsync();
            Console.WriteLine(mycontent);
    
            // Set the date in the input box:
            //     <input id="sdate" name="sdate" value="10/28/2018" ... />
            // Set value of city in multi-select:
            //     <select id="city" name="city" ...> ...
            // Click on the submit button to get results:
            //     <button type="submit" name="Submit" ...
    
            // TO DO: Write source code here.
    
    
            }
        }
        }
    }
    
    async static void Function1()
    {
    使用(HttpClient=new HttpClient())
    {
    使用(HttpResponseMessage response=wait client.GetAsync(“http://bla.com/searches/index"))
    {
    使用(HttpContent=response.content)
    {
    字符串mycontent=wait content.ReadAsStringAsync();
    控制台。写线(mycontent);
    //在输入框中设置日期:
    //     
    //在多选中设置城市值:
    //      ...
    //单击“提交”按钮以获得结果:
    
    //这里有两条主要路线。要么找出搜索页面用于与其后端服务器通信的协议并尝试直接与之通信,要么使用控制浏览器的自动化工具

    第二条路径通常更容易,使用的工具是selenium

    我建议您使用,它是围绕selenium的.NET包装器。我们主要用于端到端测试,但偶尔也用于web自动化任务


    无论您在we浏览器中使用鼠标和键盘做什么,Coypu脚本都可以自动完成。

    谢谢,我会看一看。好的,您完全正确。使用这个Coypu非常简单。一旦我获得Visual Studio项目设置和下载包,它就非常简单。