You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fmt.Println("In handler - 21")
// Create a new context
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
// Set up options for the browser session
opts := append(chromedp.DefaultExecAllocatorOptions[:],
chromedp.Headless,
chromedp.NoSandbox,
chromedp.NoFirstRun,
chromedp.DisableGPU,
chromedp.Flag("ignore-certificate-errors", true),
chromedp.Flag("disable-setuid-sandbox", true),
chromedp.Flag("disable-dev-shm-usage", true),
chromedp.Flag("single-process", true),
chromedp.Flag("no-zygote", true),
)
// Create a new context with the specified options
ctx, cancel = chromedp.NewExecAllocator(ctx, opts...)
defer cancel()
// Create a new browser session
ctx, cancel = chromedp.NewContext(ctx)
defer cancel()
// Set a timeout for the actions
ctx, cancel = context.WithTimeout(ctx, 40*time.Second)
defer cancel()
// Navigate to a webpage
url := "https://www.mywesite.com"
if err := chromedp.Run(ctx,
chromedp.Navigate(url),
chromedp.WaitVisible("#colophon", chromedp.ByQuery),
); err != nil {
fmt.Println("Failed to navigate:", err)
}
// Extract the title of the page
var title string
if err := chromedp.Run(ctx, chromedp.Title(&title)); err != nil {
fmt.Println("Failed to get title:", err)
}
fmt.Println("Page Title:", title)
var message = event.Body
greeting := message
return events.APIGatewayProxyResponse{
Body: greeting,
StatusCode: 200,
}, nil
}
AWS lambda output
START RequestId: c66d676c-a959-45f3-9664-96c8ef5897c9 Version: $LATEST
In handler - 20
Failed to navigate: exec: "google-chrome": executable file not found in $PATH
Failed to get title: exec: "google-chrome": executable file not found in $PATH
Page Title:
END RequestId: c66d676c-a959-45f3-9664-96c8ef5897c9
REPORT RequestId: c66d676c-a959-45f3-9664-96c8ef5897c9 Duration: 210.54 ms Billed Duration: 300 ms Memory Size: 503 MB Max Memory Used: 32 MB Init Duration: 89.26 ms
The text was updated successfully, but these errors were encountered:
My dockerfile
FROM golang:1.22 as build
ENV CGO_ENABLED=0
WORKDIR /app
Install CA certificates
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN mkdir -p /opt/extensions
RUN go build -o bootstrap
FROM chromedp/headless-shell:latest
COPY --from=build /app/bootstrap .
ENTRYPOINT ["./bootstrap"]
my golang code
func handler(event LambdaEvent) (events.APIGatewayProxyResponse, error) {
}
AWS lambda output
START RequestId: c66d676c-a959-45f3-9664-96c8ef5897c9 Version: $LATEST
In handler - 20
Failed to navigate: exec: "google-chrome": executable file not found in $PATH
Failed to get title: exec: "google-chrome": executable file not found in $PATH
Page Title:
END RequestId: c66d676c-a959-45f3-9664-96c8ef5897c9
REPORT RequestId: c66d676c-a959-45f3-9664-96c8ef5897c9 Duration: 210.54 ms Billed Duration: 300 ms Memory Size: 503 MB Max Memory Used: 32 MB Init Duration: 89.26 ms
The text was updated successfully, but these errors were encountered: