Reputation: 119
This code return "context error" when i start it on linux 11 server machine, but on windows 10 this code is working good. In all of machines i am installed google-chrome. What is the reason of this error?
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
ctx, cancel = chromedp.NewExecAllocator(
ctx,
append(chromedp.DefaultExecAllocatorOptions[:],
chromedp.Flag("headless", true),
chromedp.Flag("no-sandbox", true),
chromedp.Flag("disable-dev-shm-usage", true),
)...,
)
defer cancel()
ctx, cancel = chromedp.NewContext(ctx)
defer cancel()
defer chromedp.Cancel(ctx)
var TireProducts []scraper.TireProduct
ScrapeUrl := "https://www.google.com/search?q=" + url.PathEscape(scraperQueue.SearchString) + "&udm=28"
fmt.Println("start")
err := chromedp.Run(ctx,
//fetch.Enable().WithHandleAuthRequests(true),
chromedp.Navigate(ScrapeUrl),
chromedp.WaitVisible(`body`, chromedp.ByQuery), // Ожидание, пока элемент <body> станет видимым
chromedp.Sleep(2*time.Second),
)
if err != nil {
fmt.PrintLn(err)
}
I tried to install these libraries "libnss3, libxss1, libasound2, libatk1.0-0, libgtk-3-0, libgbm-dev" and tried to increase the waiting time
Upvotes: 1
Views: 128