Skip to content

Instantly share code, notes, and snippets.

@bergpb
Created June 2, 2020 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bergpb/d2935c6c4e5c840f12b825160bf5905a to your computer and use it in GitHub Desktop.
Save bergpb/d2935c6c4e5c840f12b825160bf5905a to your computer and use it in GitHub Desktop.
Scrapy de páginas com o a linguagem Go
package main
import (
"fmt"
"log"
"github.com/anaskhan96/soup"
)
var coinsURL = []string{
"https://dolarhoje.com",
"https://dolarhoje.com/euro-hoje/",
"https://dolarhoje.com/libra-hoje/",
"https://dolarhoje.com/peso-argentino/",
"https://dolarhoje.com/ouro-hoje/",
"https://dolarhoje.com/bitcoin-hoje/",
"https://dolarhoje.com/ethereum/",
"https://dolarhoje.com/dogecoin-hoje/",
"https://dolarhoje.com/dash/",
"https://dolarhoje.com/ripple-hoje/",
"https://dolarhoje.com/litecoin/",
}
func main() {
for _, el := range coinsURL {
resp, err := soup.Get(el)
if err != nil {
log.Fatal(err)
}
doc := soup.HTMLParse(resp)
if err != nil {
log.Fatal(err)
}
coinValue := doc.Find("input", "id", "nacional")
fmt.Println(coinValue.Attrs()["value"])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment