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

成功拦截ajax请求后,页面渲染是空白的 #661

Closed
feeops opened this issue Jul 15, 2022 · 2 comments
Closed

成功拦截ajax请求后,页面渲染是空白的 #661

feeops opened this issue Jul 15, 2022 · 2 comments
Labels
question Questions related to rod

Comments

@feeops
Copy link

feeops commented Jul 15, 2022

Rod Version: v0.108.1

示例代码如下

连接已打开的浏览器

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-backgrounding-occluded-windows --remote-debugging-port=9222

远程端口是9222

package main

import (
	"fmt"
	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/launcher"
	"github.com/go-rod/rod/lib/utils"
	"io/ioutil"
	"strconv"
)

func main() {

	startURL := "https://buff.163.com/goods/835753"

	var html string

	u := launcher.MustResolveURL(strconv.Itoa(9222))

	browser := rod.New().NoDefaultDevice().ControlURL(u).MustConnect()

	router := browser.HijackRequests()
	defer router.MustStop()

	router.MustAdd("*api/market/goods/sell_order*", func(ctx *rod.Hijack) {
		ctx.MustLoadResponse()
		fmt.Println(ctx.Response.Body())
	})

	go router.Run()

	page := browser.MustPage(startURL).MustWaitLoad()
	utils.Sleep(10)
	html = page.MustElement("html").MustHTML()
	ioutil.WriteFile("x.html", []byte(html), 0755)

}

能输出ajax请求的内容,但网页是空白的

@feeops feeops added the question Questions related to rod label Jul 15, 2022
@ysmood
Copy link
Collaborator

ysmood commented Jul 15, 2022

#322

@ysmood ysmood added needs info The description is not enough to tackle the problem and removed needs info The description is not enough to tackle the problem labels Jul 21, 2022
@ysmood
Copy link
Collaborator

ysmood commented Jul 21, 2022

#658

@ysmood ysmood closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2022
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

2 participants