【问题标题】:How can you find and click an image on a webpage?如何在网页上找到并单击图像?
【发布时间】:2013-08-25 08:01:50
【问题描述】:

我正在尝试在网页上找到一个按钮并单击它。这是我尝试为此制作的脚本:

IfWinExist,谷歌 - Mozilla Firefox 赢激活 ImageSearch, Foundx, Foundy, 18, 69, 371, 328, C:\users\bob\desktop\google.png 如果错误级别 MsgBox,找不到图像。 别的, 鼠标移动

这显然不是我的实际脚本,但它是相同的命令。我想要一个脚本来定位页面上的图像,将鼠标移动到图像的中心,然后单击。我的脚本的问题是我无法保存找到的图像的坐标并将鼠标移动到它。

【问题讨论】:

    标签: image search click mouse move


    【解决方案1】:

    您需要确定搜索表单是发出 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

    【讨论】:

      猜你喜欢
      • 2021-03-31
      • 1970-01-01
      • 2020-09-24
      • 1970-01-01
      • 2023-01-10
      • 2017-01-27
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      相关资源
      最近更新 更多