随笔分类 - 自动化
摘要:from playwright.sync_api import Playwright, sync_playwright def request_interceptor(route, request): logger.info(request.url) if 'api.js' in request.u
阅读全文
摘要:await this._page.waitForLoadState('networkidle'); await this._page.waitForLoadState('load') await this._page.waitForLoadState('domcontentloaded') awai
阅读全文
摘要:以下是一个Node.js版的Playwright等待所有请求完成的Demo喵~: ```javascript const { chromium } = require('playwright'); (async () => { const browser = await chromium.launc
阅读全文
摘要:在Node.js中,您可以使用`robotjs`模块来操作鼠标和键盘。以下是一个根据鼠标坐标单击的示例: ```javascript const robot = require("robotjs"); // set the mouse position to (x,y) const x = 100;
阅读全文
摘要:在使用Node.js版的Playwright时,可以通过以下步骤启动自定义浏览器: 1. 导入所需模块和类: ``` const { chromium } = require('playwright'); ``` 2. 创建自定义浏览器选项: ``` const browserOptions = {
阅读全文
摘要:可以使用 `page.mouse.click(x, y)` 方法通过坐标点击页面的指定位置。 例如,假设你需要在页面上坐标 $(100, 200)$ 的位置进行点击,可以使用以下代码: ```javascript const { chromium } = require('playwright');
阅读全文
摘要:要在 Node.js 中使用 Playwright 定位到一个 iframe 并获取其在屏幕中的位置,可以按照以下步骤进行: 1. 使用 `page.frame()` 方法获取 iframe 元素的句柄: ```javascript const frame = await page.frame({
阅读全文
摘要:在 playwright 中,页面加载完成有多种判断方式,下面给出几种实现方式: 1. 监听 `load` 事件,等待全部资源加载完成。 ```javascript const { chromium } = require('playwright'); (async () => { const br
阅读全文
摘要:router.MustAdd("*/api/v2", func(ctx *rod.Hijack) { //ctx.MustLoadResponse() log.Println("进来过") ctx.Response.SetBody(`{"cards":"","}`) })
阅读全文
摘要:result := page.MustEval(`() => window.location.href`) result.String()
阅读全文
摘要:sMap := make(map[string]string) for _, cookie := range page.MustCookies() { //log.Printf("chrome cookie %d: %+v", i, cookie) sMap[cookie.Name] = cooki
阅读全文
摘要:page.MustWait(`() => { window.astr = Array.from(document.querySelectorAll('#noResult > div > div > p:nth-child(3)')).map( article=>article.innerHTML).
阅读全文
摘要:u := launcher.New(). Headless(false). //Devtools(true). Bin("E:\\Chrome-bin\\chrome.exe").MustLaunch() browser := rod.New().ControlURL(u). //Trace(tru
阅读全文
摘要:if page.MustHas("button#onetrust-accept-btn-handler") { page.MustElementX("//button[@id=\"onetrust-accept-btn-handler\"]").MustClick() }
阅读全文
摘要:expr := proto.TimeSinceEpoch(time.Now().Add(180 * 24 * time.Hour).Unix()) page.MustSetCookies(&proto.NetworkCookieParam{ Name: "cookiename", Value: "v
阅读全文
摘要:err := rod.Try(func() { page.Timeout(60 * time.Second).MustNavigate(url).MustWaitLoad().CancelTimeout() }) if errors.Is(err, context.DeadlineExceeded)
阅读全文
摘要:https://github.com/go-rod/go-rod-chinese/blob/186e2fcf0611f0fcea74e723d82e079bd724ce8f/lib/examples/launch-managed/main.go
阅读全文
摘要:https://github.com/go-rod/go-rod-chinese/blob/186e2fcf0611f0fcea74e723d82e079bd724ce8f/lib/examples/compare-chromedp/cookie/main.go // read network va
阅读全文

浙公网安备 33010602011771号