mirror of
https://github.com/bestnite/bilinovel-downloader.git
synced 2025-10-26 09:11:01 +00:00
refactor(bilinovel): Migrate browser automation from Chromedp to Playwright
This commit replaces the `chromedp` library with `playwright-go` for browser automation within the Bilinovel downloader. Changes include: * Updated `Bilinovel` struct to manage Playwright browser, context, and page instances. * Rewrote `initBrowser` and `Close` methods to use Playwright's API for browser lifecycle management. * Refactored `processContentWithChromedp` to `processContentWithPlaywright`, adapting the logic to use Playwright's page evaluation capabilities. * Removed unused `context` and `time` imports. * Added HTML cleanup in `getChapterByPage` to remove `class` attributes from images and `data-k` attributes from all elements, improving content consistency.
This commit is contained in:
12
main.go
12
main.go
@@ -2,8 +2,20 @@ package main
|
||||
|
||||
import (
|
||||
"bilinovel-downloader/cmd"
|
||||
"io"
|
||||
"log"
|
||||
|
||||
"github.com/playwright-community/playwright-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("Installing playwright")
|
||||
err := playwright.Install(&playwright.RunOptions{
|
||||
Browsers: []string{"chromium"},
|
||||
Stdout: io.Discard,
|
||||
})
|
||||
if err != nil {
|
||||
log.Panicf("failed to install playwright")
|
||||
}
|
||||
_ = cmd.RootCmd.Execute()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user