Webscraping using html selector

Trying to get some data using the html/css selector div.ipchecker which shows an object of a clients details in the site https://ipstack.com/
Heres my code

package main

import (
	"fmt"
	"net/http"

	"github.com/PuerkitoBio/goquery"
)

const (
	site1 = "https://ipstack.com/"
	site2 = "https://geoip.nekudo.com"
)

var count int

func get(s string) (count int, body string) {
	resp, err := http.Get(s)
	if err != nil {
		return 0, err.Error()
	}
	defer resp.Body.Close()

	count++

	doc, _ := goquery.NewDocumentFromReader(resp.Body)

	return count, doc.Find("div.ipchecker").Text()
}

func main() {
	_, b := get(site1)
	fmt.Println(b)
}

Im using goquery but when i run the program, i dont get the full object, rather im getting just the button on the top right corner. I doubt theres a way to hide data when trying to scrape it through the selector. Not sure what the issue ism Maybe theres a better way to scrape the object?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.