goQuery Web Scraping

Asked 2 years ago, Updated 2 years ago, 87 views

doc,err:=goquery.NewDocument("https://translate.google.co.jp/?hl=ja#en/ja/apple")
if err!=nil{
    fmt.Print ("url scarapping failed")
}
fmt.Println(doc.Find("span#result_box").Text())
}

I'd like to get Google translation results on jquery, but the translation results are displayed

<span id="result_box">(shown here)</span>

There is a blank space in .
It was done when I implemented it in python, but I can't do it in go. Why?

go web-scraping

2022-09-29 22:45

1 Answers

When I tried opening https://translate.google.co.jp/?hl=ja#en/ja/apple, I found this DOM structure.

<span id="result_box" class="short_text" lang="ja">span class="">Apple</span>>

If you take blank characters from the sample code, I think you can get them.

doc.Find("span#result_box").Text()


2022-09-29 22:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.