golang开发一个真人鼠标轨迹程序,python+selenium打开网站后调用goMouse.exe实现鼠标曲线移动,让采集完全符合真人操作,突破平台防采集而加入的检测鼠标轨迹事件。

您所在的位置:网站首页 鼠标移动事件代码 golang开发一个真人鼠标轨迹程序,python+selenium打开网站后调用goMouse.exe实现鼠标曲线移动,让采集完全符合真人操作,突破平台防采集而加入的检测鼠标轨迹事件。

golang开发一个真人鼠标轨迹程序,python+selenium打开网站后调用goMouse.exe实现鼠标曲线移动,让采集完全符合真人操作,突破平台防采集而加入的检测鼠标轨迹事件。

2023-07-11 05:28| 来源: 网络整理| 查看: 265

序言:

平台防数据采集的技术日趋完善,科学收集数据来指导企业操作又是正规IT工作者的诉求。我们要安全,高效,合理,遵守法律法规,不造成平台访问压力,收集公开的允许数据是工作的内容,也是责任担当。现在给大家讲一下真人鼠标轨迹曲线运动的突破。

golang代码如下: package main import ( "fmt" "github.com/go-vgo/robotgo" "github.com/lxn/win" "math/rand" "time" ) func RandInt(min, max int) int { if min >= max || min == 0 || max == 0 { return max } return rand.Intn(max-min+1) + min } func max(num1, num2 int) int { /* 声明局部变量 */ var result int if num1 > num2 { result = num1 } else { result = num2 } return result } func min(num1, num2 int) int { /* 声明局部变量 */ var result int if num1 > num2 { result = num2 } else { result = num1 } return result } func main() { min1 := 0.4 max1 := 0.9 randFloat := rand.Float64()*(max1-min1) + min1 time.Sleep(time.Second * 1) width := int(win.GetSystemMetrics(win.SM_CXSCREEN)) height := int(win.GetSystemMetrics(win.SM_CYSCREEN)) fmt.Printf("%dx%d\n", width, height) // 获取当前鼠标所在的位置 //x, y := robotgo.GetMousePos() //println(`x:`, x, ` y:`, y) robotgo.MoveMouseSmooth(min(115+RandInt(10, 100), width), min(128+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(149+RandInt(10, 100), width), min(130+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(850+RandInt(10, 100), width), min(94+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(1570+RandInt(10, 100), width), min(447+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(1152+RandInt(10, 100), width), min(728+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(424+RandInt(10, 100), width), min(717+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(182+RandInt(10, 100), width), min(440+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(115+RandInt(10, 100), width), min(128+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(149+RandInt(10, 100), width), min(130+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(850+RandInt(10, 100), width), min(94+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(1570+RandInt(10, 100), width), min(447+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(1152+RandInt(10, 100), width), min(728+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(424+RandInt(10, 100), width), min(717+RandInt(10, 100), height), randFloat, randFloat) robotgo.MoveMouseSmooth(min(182+RandInt(10, 100), width), min(440+RandInt(10, 100), height), randFloat, randFloat) robotgo.ScrollMouse(600, `down`) println("down") time.Sleep(time.Second * 1) // 向上滚动:3行 robotgo.ScrollMouse(600, `up`) }

python+senium代码部分如下: chrome_options = webdriver.ChromeOptions() # chrome_options.add_argument('--proxy-server={0}'.format(self.proxy.proxy)) # chrome_options.add_argument('--blink-settings=imagesEnabled=false') chrome_options.add_argument("--disable-blink-features=AutomationControlled") # 禁用启用Blink运行时的功能 chrome_options.add_experimental_option("excludeSwitches", ["enable-automation","enable-logging"]) # chrome_options.add_argument('--ignore-certificate-errors') prefs = {"": ""} prefs["credentials_enable_service"] = False prefs["profile.password_manager_enabled"] = False chrome_options.add_experimental_option("prefs", prefs) # 屏蔽'保存密码'提示框 chrome_options.add_argument('--proxy-server=http://127.0.0.1:9099') chrome_options.add_argument('--user-data-dir='+cookie_path) self.driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=get_chromedriver_path) with open(f'{cur_path}'+'/stealth.min.js', encoding='utf-8') as f: js = f.read() self.driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", { "source": js }) self.curr_status() os.popen(cur_path + '\\' + 'goMouse.exe').read() self.view_detail()

goMouse.exe是鼠标移动轨迹,上面golang代码编译而来。

总结

本技术仅供学习之用,切勿用于违法之地。科技因你我担当而充满魅力,欢迎私聊。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3