Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "net/http"
- "github.com/PuerkitoBio/goquery"
- )
- func main() {
- // URL to make the HTTP request to
- url := "https://scrapeme.live/shop"
- // Make the GET request
- resp, _ := http.Get(url)
- defer resp.Body.Close()
- // Use goquery to parse the HTML
- doc, _ := goquery.NewDocumentFromReader(resp.Body)
- // Extract names of Pokémon
- var pokemonNames []string
- doc.Find("h2").Each(func(i int, s *goquery.Selection) {
- pokemonNames = append(pokemonNames, s.Text())
- })
- // Print the extracted Pokémon names
- for _, name := range pokemonNames {
- fmt.Println(name)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement