Closed s0kil closed 4 years ago
Why not get cookies using an HTTP request? The browser extension is too much hassle.
package main import ( "bytes" "fmt" "net/http" ) var username = "InstaUsername" var password = "InstaPassword" func main() { url := "https://www.instagram.com/accounts/login/ajax/" var params = []byte(fmt.Sprintf(`username=%s&password=%s&queryParams={}`, username, password)) req, err := http.NewRequest("POST", url, bytes.NewBuffer(params)) req.Header.Set("user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.139 Chrome/66.0.3359.139 Safari/537.36") req.Header.Set("content-type", "application/x-www-form-urlencoded") req.Header.Set("x-requested-with", "XMLHttpRequest") req.Header.Set("x-csrftoken", "Xz7lgke9oJh9CV8c2HjY2o0tB4EvQedb") req.Header.Set("cookie", "csrftoken=Xz7lgke9oJh9CV8c2HjY2o0tB4EvQedb; rur=FTW; mid=Wv1kwwAEAAF10fw8f1pJ9zUc4HcT") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() fmt.Println("response Cookies:", resp.Cookies()) }
Good idea! But I use Facebook login. Does the sample code here also work for Facebook login? Thanks
I don't think so.
Why not get cookies using an HTTP request? The browser extension is too much hassle.