Created
June 2, 2020 19:16
-
-
Save bergpb/d2935c6c4e5c840f12b825160bf5905a to your computer and use it in GitHub Desktop.
Scrapy de páginas com o a linguagem Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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