我正在尝试在网页上找到一个按钮并单击它。这是我试图为此做的一个脚本:
IfWinExist,Google - Mozilla Firefox WinActivate ImageSearch,Foundx,Foundy,18,69,371,328,C:\ users \ bob \ desktop \ google.png 如果是ErrorLevel MsgBox,找不到图片。 其他, 的MouseMove
这显然不是我的实际脚本,但它是相同的命令。我想要一个脚本在页面上定位图像,将鼠标移动到图像的中心,然后单击。我的脚本问题是我无法保存找到的图像的坐标并将鼠标移动到它。
答案 0 :(得分:0)
您需要确定搜索表单是否发出POST或GET请求。 GET请求意味着值在查询字符串中传递。您可以通过Google看到这一点。您需要做的就是制定自己的查询字符串以包含搜索词并使用它来创建HttpWebRequest。如果是POST请求,则需要使用稍微不同类型的HttpWebRequest。它传递Form集合中的值而不是QueryString。
这是一篇基本使用GET请求的文章:http://www.mikesdotnetting.com/Article/49/How-to-read-a-remote-web-page-with-ASP.NET-2.0。表单请求的方法如下:
public static string HttpPostRequest(string url, string post)
{
var encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(post);
WebRequest request = WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
WebResponse response = request.GetResponse();
String result;
using (var sr = new StreamReader(response.GetResponseStream()))
{
result = sr.ReadToEnd();
sr.Close();
}
return result;
}
来自“Mikesdotnetting”的回答 在:http://forums.asp.net/t/1495798.aspx/1