rod
rod copied to clipboard
Throttling with Hijack requests
Hi, i tried use Throttling with Hijack requests but throttling have not effect when turn on hijack requests
https://www.youtube.com/watch?v=cz0K-Of8scc ==> alway play with 144p quality if only throttling but i combine throttling with hijack requests , it will alway play with 720p quality
// Package main ...
package main
import (
"fmt"
"strings"
"time"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/launcher"
"github.com/go-rod/rod/lib/proto"
"github.com/kataras/golog"
)
func main() {
u := launcher.MustResolveURL("127.0.0.1:3990")
browser := rod.New().ControlURL(u).MustConnect()
page := browser.MustConnect().MustPage("")
page.EnableDomain(proto.NetworkEnable{})
errEmulate3G := proto.NetworkEmulateNetworkConditions{
Offline: false,
Latency: 20,
DownloadThroughput: 2024,
UploadThroughput: 7500,
ConnectionType: proto.NetworkConnectionTypeCellular3g,
}.Call(page)
if errEmulate3G != nil {
golog.Error(errEmulate3G)
}
router := page.HijackRequests()
router.MustAdd("*", func(ctx *rod.Hijack) {
if strings.Contains(ctx.Request.URL().String(), "googlevideo.com") {
ctx.MustLoadResponse()
//fmt.Println(ctx.Response.Body())
fmt.Println(ctx.Request.URL().String())
} else {
ctx.ContinueRequest(&proto.FetchContinueRequest{})
}
})
page.MustNavigate("https://www.youtube.com/watch?v=cz0K-Of8scc").MustWaitLoad()
time.Sleep(time.Hour)
}
Please add a valid Rod Version: v0.0.0 to your issue. Current version is v0.112.0
Please fix the format of your markdown:
4 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
4 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
60 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]
generated by check-issue
@Phuong39 Check the source code of MustLoadResponse, you will understand why, rod's code is designed to be its doc.
#395