Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hijack无法加载Other类型请求 #999

Closed
DC3x6 opened this issue Jan 4, 2024 · 7 comments
Closed

hijack无法加载Other类型请求 #999

DC3x6 opened this issue Jan 4, 2024 · 7 comments
Labels
question Questions related to rod

Comments

@DC3x6
Copy link
Contributor

DC3x6 commented Jan 4, 2024

Rod Version: v0.114.1

hijack无法加载Other类型请求

  1. 代码
 package main

import (
	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/launcher"
	"github.com/go-rod/rod/lib/proto"
	"time"
)

func main() {
	launcher := launcher.New().
		Headless(true).
		Bin(path).
		MustLaunch()
	browser := rod.New().NoDefaultDevice().ControlURL(launcher).MustConnect().MustIgnoreCertErrors(true)
	defer browser.MustClose()
	page := browser.Timeout(20 * time.Second).MustPage().MustWaitLoad()
	//hijack
	router := page.HijackRequests()
	defer router.MustStop()
	router.MustAdd("*", func(ctx *rod.Hijack) {
		println(ctx.Request.Type(), ctx.Request.URL().String())
		ctx.ContinueRequest(&proto.FetchContinueRequest{})
	})
	go router.Run()
	waitNavigation := page.MustWaitNavigation()
	page.Navigate("https://www.wikipedia.org/")
	waitRequestIdle := page.WaitRequestIdle(2*time.Second, nil, nil, nil)
	waitNavigation()
	waitRequestIdle()
}

hedless=true

Document https://www.wikipedia.org/
Image https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png
Image https://www.wikipedia.org/portal/wikipedia.org/assets/img/sprite-8bb90067.svg
Script https://www.wikipedia.org/portal/wikipedia.org/assets/js/index-6eac697e63.js
Script https://www.wikipedia.org/portal/wikipedia.org/assets/js/gt-ie9-ce3fe8e88d.js
Image https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikinews-logo_sister.png
XHR https://www.wikipedia.org/portal/wikipedia.org/assets/l10n/zh-hans-df1f0a78.json

headless=false

Document https://www.wikipedia.org/
Image https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2@2x.png
Image https://www.wikipedia.org/portal/wikipedia.org/assets/img/sprite-8bb90067.svg
Script https://www.wikipedia.org/portal/wikipedia.org/assets/js/index-6eac697e63.js
Script https://www.wikipedia.org/portal/wikipedia.org/assets/js/gt-ie9-ce3fe8e88d.js
Image https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikinews-logo_sister@2x.png
XHR https://www.wikipedia.org/portal/wikipedia.org/assets/l10n/zh-hans-df1f0a78.json
Other https://www.wikipedia.org/static/favicon/wikipedia.ico
@DC3x6 DC3x6 added the question Questions related to rod label Jan 4, 2024
Copy link

github-actions bot commented Jan 4, 2024

Please fix the format of your markdown:

41 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## hedless=true"]
42 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"]
52 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## headless=false"]
53 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```bash"]

generated by check-issue

@ysmood
Copy link
Member

ysmood commented Jan 4, 2024

跟 favicon 相关 @Fly-Playgroud

@DC3x6
Copy link
Contributor Author

DC3x6 commented Jan 5, 2024

那个我知道,我试了,那个方法并不适用所有网站

@ysmood
Copy link
Member

ysmood commented Jan 5, 2024

只有 favicon 不会显示,你可以看看这个 PR #884

@Fly-Playgroud
Copy link
Contributor

那个我知道,我试了,那个方法并不适用所有网站

如果你不想使用 trigerFavicon 那么你可以实验性的选择开启 new headless 模式,在此模式下 网站的 favicon 请求会被自动触发。推荐使用的浏览器版本 112+ @ysmood @DC3x6

@Fly-Playgroud
Copy link
Contributor

另外即使自动触发成功,也会出现404的情况, chrome 的触发方式 和 triggerFavicon 的大同小异,没有什么特别的

@DC3x6 DC3x6 closed this as completed Jan 15, 2024
@DC3x6
Copy link
Contributor Author

DC3x6 commented Jan 15, 2024

已解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

3 participants