我正在尝试自动化页面搜索结果并使用 C# 将结果放入 JSON 或 CSV 文件中。
大纲是:
- 转到网页。
- 更改日期(HTML 输入修改)
- 选择城市(HTML多选修改)
- 点击提交按钮(名为提交的 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.
}
}
}
}
什么是一个很好的资源或阅读以了解如何在 Web 浏览器中使用鼠标和键盘来完成这些步骤?