Give a hint. I do a parser. For parsing, I need to log in to the site. But the site scorches that sending the login and password is not from the browser. Here's what curl looks like:

  $this->ch = curl_init(); curl_setopt($this->ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"); curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($this->ch, CURLOPT_COOKIEFILE, 'user_cookie_file.txt'); curl_setopt($this->ch, CURLOPT_COOKIEJAR, 'user_cookie_file.txt'); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($this->ch, CURLOPT_URL, PAGEAUTHORIZATION); curl_setopt($this->ch, CURLOPT_POST, 1); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->postData); curl_setopt($this->ch, CURLOPT_REFERER, PAGEAUTHORIZATION); $error = curl_exec($this->ch); 

Parameters in the post request send everything you need. Authorization sometimes passes, example 1 time out of 20 attempts. In other cases, the report receives a page of the site with a warning of suspicious activity. Please give advice.

    1 answer 1

    Try to look at the headers that you send when you log in using a browser, and then substitute these headers into your request via curl

    curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headers);

    Here it depends on a particular site who thinks out what to protect themselves and the data.

    • It worked, but not for long. There is a header that the browser "Cookie:" sends there is a lot of data. Hike them like the site understands after a while that I am a robot. Do not tell me exactly what criteria he can understand? The list of cookies there is simply dimensionless and 80% unreadable. - Winteriscoming
    • For cookies, CURLOPT_COOKIEFILE CURLOPT_COOKIEJAR is used and they already exist. You can try another such option - do not immediately send this request to curl and just send a GET request to the authorization page before it, i.e. simulate user actions "Entering the page" -> "Submitting a form" Sometimes developers make it so that when entering the authorization page, they immediately hang up the cookies that need to be used later when sending POST data - WebSiteCoder
    • In one session curl / _init or in different? - Winteriscoming
    • Try different - WebSiteCoder
    • I tried everything. Now even in .NET I try, the same result. It works only if I’m in the cookie, before the post request, stuff the cookies that the browser sends, there they are ugly long, it’s in the request that they plow. Xs how to change them .... - Winteriscoming