我正在尝试自动执行页面搜索结果,并使用C#将结果放入JSON或CSV文件中。
大纲是:
我可以获取初始页面(第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.
}
}
}
}
什么是很好的资源,或者可以用来弄清楚如何用Web浏览器中的鼠标和键盘执行这些步骤?
答案 0 :(得分:1)
这里有两条主要路线。您要么确定搜索页面用于与其后端服务器通信的协议,然后尝试直接与后端服务器通信,要么使用控制浏览器的自动化工具。
第二条路径通常更容易使用,并且使用的工具是硒。
我建议您使用Coypu,它是围绕硒的.NET包装器。我们主要将其用于端到端测试,但也偶尔用于Web自动化任务。
无论您在We浏览器中使用鼠标和键盘做什么,Coypu脚本都可以自动完成。