I am learning "Go" for web crawling. I would like to take some text from following site: "https://edition.cnn.com/markets/fear-and-greed"
This site need waiting time to load all html text. So I have used chromedp to get the text from this site.
However, when I run this script, there is no response. The code is
package main
import (
"context"
"log"
"strings"
"github.com/chromedp/chromedp"
)
func main() {
opts := append(chromedp.DefaultExecAllocatorOptions[:],
chromedp.Flag("headless", false),
)
ctx, cancel := chromedp.NewExecAllocator(context.Background(), opts...)
defer cancel()
ctx, cancel = chromedp.NewContext(ctx)
defer cancel()
var res string
err := chromedp.Run(ctx,
chromedp.Navigate("https://edition.cnn.com/markets/fear-and-greed"),
chromedp.Text(".market-fng-gauge__dial-number-value", &res, chromedp.NodeVisible),
)
if err != nil {
log.Fatal(err)
}
log.Println(strings.TrimSpace(res))
}
What is Wrong? I really want to scrap this site using "Go". Please let me know how to do.