本地API进行常规自动化操作

  • 启动接口添加参数 notifications=2 可以禁止网站通知提示框

  • http://127.0.0.1:35000/api/v1/profile/start?profileId=xxxxxxxxxxx&skiplock=true¬ifications=2

  • 鼠标点击:GET传参x,y坐标为鼠标点击的坐标,页面可视的左上角为0,0基点。

  • http://127.0.0.1:35000/api/v1/profile/page/mouseclick?x=400&y=500&profileId=xxxx

  • 返回例:{"status":"OK","success":true,"value":"{}"}

  • 如果 success = true 表示执行成功

  • 鼠标滚轮:GET传参x,y坐标为鼠标所在的坐标,deltaY为滚轮上下滚动值,负数是上向滚动,正数是向下滚动。

  • http://127.0.0.1:35000/api/v1/profile/page/mousewheel?x=400&y=500&deltaX=0&deltaY=50&profileId=xxxx

  • 返回例:{"status":"OK","success":true,"value":"{}"}

  • 如果 success = true 表示执行成功

  • 页面信息查询:GET传参profileId配置文件ID,可以读取当前页的网址,标题,是否加载完成信息。

  • http://127.0.0.1:35000/api/v1/profile/page/pagestate?profileId=xxxx

  • 返回例1:{"status":"OK","value":"","success":true,"baseURI":"https://cn.bing.com/","readyState":"interactive","title":"必应"}

  • 返回例2:{"status":"OK","value":"","success":true,"baseURI":"https://cn.bing.com/","readyState":"complete","title":"必应"}

  • 如果success=true表示执行成功,baseURI为当前页网址,readyState为complete页面加载完成。title为标题

  • 前进

  • http://127.0.0.1:35000/api/v1/profile/historyforward?profileId=xxxx

  • 后退

  • http://127.0.0.1:35000/api/v1/profile/historyback?profileId=xxxx

  • 优化代理检测接口(添加主动超时参数 timeout 毫秒,超时自动返回)

  • http://127.0.0.1:35000/api/v1/proxy/test?proxytype=socks5&proxyserver=127.0.0.1&proxyport=1080&proxyusername=&proxypassword=&timeout=8000

  • 表示如果测试代理8秒没结果就不等了,失败返回。

  • 刷新页面

  • http://127.0.0.1:35000/api/v1/profile/refresh?profileId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

  • 当前标签打开指定网址

  • http://127.0.0.1:35000/api/v1/profile/openurl?profileId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&url=www.vmlogin.com.cn

  • 获取网页源代码

  • http://127.0.0.1:35000/api/v1/profile/source?profileId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

  • 寻找网页中的元素

  • http://127.0.0.1:35000/api/v1/profile/findElement?profileId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&function=findElementByID&args=kw&click=false&index=-1

  • function参数支持:

  • findElementByID

  • findElementByTag

  • findElementByClassName

  • findElementByLinkText

  • findElementByXPath

  • findElementsByID

  • findElementsByTag

  • findElementsByClassName

  • findElementsByLinkText

  • findElementsByXPath

  • args参数为function函数的传参,如:findElementByID(args)

  • click为true时,找到指定元素后进行点击操作。为false时不进行点击

  • index是元素有多个时,指定点击第几个元素,从0开始,-1为随机元素其中一个,这个参数是配合click=true时使用的。

  • 取指定元素属性值

  • http://127.0.0.1:35000/api/v1/profile/getAttribute?profileId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&args=[{"ELEMENT": "95365abe-6746-4703-8cfd-6316580f5289", "element-6066-11e4-a52e-4f735466cecf": "95365abe-6746-4703-8cfd-6316580f5289"}, "style"]

  • args参数,一般是通过findElement查找元素后得到的Element_ID结合成的JSON串。如:[{"ELEMENT": "95365abe-6746-4703-8cfd-6316580f5289", "element-6066-11e4-a52e-4f735466cecf": "95365abe-6746-4703-8cfd-6316580f5289"}, "value"]

  • 这个就是取 95365abe-6746-4703-8cfd-6316580f5289 元素的 value 值。

  • 通过选择器执行元素点击

  • http://127.0.0.1:35000/api/v1/profile/findElement?profileId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&function=findElementByID&args=kw&click=true&index=-1

  • 发送文字到网页中

  • http://127.0.0.1:35000/api/v1/profile/sendKeys?profileId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&elementId=95365abe-6746-4703-8cfd-6316580f5289&value=abc

  • elementId参数一般是通过findElement查找元素后得到的elementId,value=abc,就是换这个网页控件中发送abc字符串。注意网页要加载完毕才能进行这些自动化操作,不然有可能动作会被阻塞。

  • 这里的35000端口,是VMLogin 客户端软件中我的帐号里设置的端口,注意开启和变化。

  • 客户端重启接口

  • http://127.0.0.1:35000/api/v1/client/restart

  • 测试代理的接口

  • http://127.0.0.1:35000/api/v1/proxy/test?proxytype=socks5&proxyserver=127.0.0.1&proxyport=1080&proxyusername=&proxypassword=

  • proxytype可用参数:socks5/socks4/http/https

  • {"status":"ERROR","value":"Failed to test the proxy server."}

  • {"status":"OK","value":"country:HK\r\ncity:Central\r\nregion:HCW\r\ntz:Asia\/Hong_Kong\r\n"}