示例#1
0
func getReleases() []map[string]interface{} {
	response, _ := request.Get(Url, map[string]string{})

	defer response.Body.Close()

	body, _ := ioutil.ReadAll(response.Body)

	if err := json.Unmarshal(body, &releases); err != nil {
		panic(err)
	}

	return releases
}
示例#2
0
文件: page.go 项目: BrettBukowski/how
// Get the document for the link.
// Requests the page with a randomized user-agent
// so Google doesn't get suspicious. ಠ_ಠ
func (p *Page) Fetch() (*goquery.Document, error) {
	var response *http.Response
	var doc *goquery.Document
	var e error

	if response, e = request.Get(p.Url, map[string]string{
		"User-Agent": userAgents[rand.Intn(len(userAgents))],
	}); e != nil {
		return nil, e
	}

	if doc, e = goquery.NewDocumentFromResponse(response); e != nil {
		panic(e.Error())
	}
	return doc, nil
}