Скручивание URL невозможно после некоторого сокращения - PullRequest
0 голосов
/ 24 сентября 2019

Я удалил результат перенаправления со спуфингом.После почти года без проблем получил то, что я хочу, и вдруг он перестал работать.В браузере работает отлично, но с curl я получаю только URL с ошибкой 404 на другом сервере.Я перенаправлен на неправильный URL.Вот мой код.

    function curl_spoofred($url) 
{
        $curl = curl_init();

    //set some headers if you want 
        $header[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
        $header[] = "Cache-Control: max-age=0";
        $header[] = "Connection: keep-alive";
        $header[] = "Keep-Alive: 300";

        curl_setopt($curl, CURLOPT_URL, $url);

    //Spoof the agent
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36');

    //Spoof the Referer
        curl_setopt($curl, CURLOPT_REFERER, 'https://wwv.example.com');
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

        curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
        curl_setopt($curl, CURLOPT_COOKIESESSION, true);
        curl_setopt($curl, CURLOPT_FAILONERROR, true);
        curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate,br');
        curl_setopt($curl, CURLOPT_AUTOREFERER, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        if (!$html = curl_exec($curl))
    { 

    }
return curl_getinfo($curl,CURLINFO_EFFECTIVE_URL );
            curl_close($curl);
}

После проверки сетевой консоли в Chrome он дал мне следующее:

Request URL: https://www.example.com/video.php?p=2&c=V1RKa2RHTlRhXbTFhUbmtvMVRWYzRQUT09&id=631
Request Method: GET
Status Code: 301 
Remote Address: 104.26.5.130:443
Referrer Policy: no-referrer-when-downgrade
cache-control: max-age=3600
cf-ray: 51b45707fb1969aa-CDG
date: Tue, 24 Sep 2019 11:15:20 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
expires: Tue, 24 Sep 2019 12:15:20 GMT
location: https://www.example.com/video.php?p=2&c=V1RKa2RHTlRhXbTFhUbmtvMVRWYzRQUT09&id=631
server: cloudflare
status: 301
vary: Accept-Encoding
:authority: www.example.com
:method: GET
:path: /video.php?p=2&c=V1RKa2RHTlRhXbTFhUbmtvMVRWYzRQUT09&id=631
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
accept-encoding: gzip, deflate, br
accept-language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,ar;q=0.6
cookie: __cfduid=d948bdac17ae9dca8577dffc6dc3509cd1565743125; _ga=GA1.2.1798570479.1565743125; HstCfa2982759=1565743132096; __dtsu=3DD172A73239535D5B772D7602A61C9A; HstCmu2982759=1568475393523; HstCla2982759=1568892578738; HstPn2982759=1; HstPt2982759=96; HstCnv2982759=18; HstCns2982759=34; _gid=GA1.2.1495236200.1569313316; _gat_gtag_UA_138212094_1=1
referer: https://wwv.example.com/some-article.htm
sec-fetch-mode: nested-navigate
sec-fetch-site: same-site
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
p: 2
c: V1RKa2RHTlRhXbTFhUbmtvMVRWYzRQUT09
id: 631

Надеюсь, вы поможете мне с этим.С уважением.

...