Is there a good way to set a pre-existing cookie value to a phantomgo request? (The cookie was set from an initial login using the go http library)
I have a *cookiejar.Jar that should have all the values necessary for logging into a website persistently; I want to get information from a webpage that has some dynamic information displayed and it (the page) requires trying to interpret a series of JS scripts, therefore the reason I'm trying to fetch the page with phantomgo.
I'm not sure how to set up a cookie through phantomgo; do I craft a map that is passed into the Header of &phantomgo.Param{}? Or do I try translating the *cookiejar.Jar to a string?
The basics of what I'm trying now:
func GetURL(strURL string) string {
chnMsgDebugMessage <- "Processing " + strURL + " in CheckURL()"
p := &phantomgo.Param{
Method: "GET",
Url: strURL,
Header: http.Header{"User-Agent": []string{"MyBrowser"}},
UsePhantomJS: true,
}
browser := phantomgo.NewPhantom()
res, err := browser.Download(p)
if err != nil {
panic(err)
}
body, err := ioutil.ReadAll(res.Body)
strVal := string(body)
res.Close
WriteToFile("debugging.html", strVal)
// Done
return strVal
}