Get html content from howlongtobeat

Hello im making a post to howlongtobeat but i dont get the html response i only get form-data values.

this same think works perfect in postman

func HowLongToBeat() {
	form := url.Values{}
	form.Add("queryString", "doom")
	form.Add("t", "games")
	form.Add("sorthead", "popular")
	form.Add("sortd", "Normal Order")
	form.Add("plat", "")
	form.Add("length_type", "main")
	form.Add("length_min", "")
	form.Add("length_max", "")
	form.Add("detail", "0")
	form.Add("v", "")
	form.Add("f", "")
	form.Add("g", "")
	form.Add("randomize", "0")

	req, err := http.NewRequest("POST", "https://howlongtobeat.com/search_results?page=1", strings.NewReader(form.Encode()))

	req.Header.Add("Content-type", "application/x-www-form-urlencoded")
	req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36")
	req.Header.Add("Accept", "*/*")
	req.Header.Add("origin", "https://howlongtobeat.com")
	req.Header.Add("referer", "https://howlongtobeat.com")

	if err != nil {
		//handle postform error
		fmt.Println(err)
	}

	defer req.Body.Close()
	body, err := ioutil.ReadAll(req.Body)

	if err != nil {
		//handle read response error
		fmt.Println(err)
	}

	fmt.Println(string(body))
            //this prints (detail=0&f=&g=&length_max=&length_min=&length_type=main&plat=&queryString=doom&randomize=0&sortd=Normal+Order&sorthead=popular&t=games&v=)
}

Hi @illud
For control over HTTP client headers, redirect policy, and other settings, create a Client:

client := &http.Client{
	CheckRedirect: redirectPolicyFunc,
}

resp, err := client.Get("http://example.com")
// ...

req, err := http.NewRequest("GET", "http://example.com", nil)
// ...
req.Header.Add("If-None-Match", `W/"wyzzy"`)
resp, err := client.Do(req)
// ...
1 Like

Thank you!