Answer the question
In order to leave comments, you need to log in
Why doesn't it find the page with requests, but finds it with cURL and Go?
I make a request to a page in python using requests - the server responds with a page with the title "page not found"
the same but cURL - I
tried everything fine GO - I also get the necessary data, even if I don't send headers and coockie
example url
in python:
import requests
import coockie
main_url = coockie.host
def main():
r = requests.get(main_url, headers=coockie.headers, cookies=coockie.cookies)
return bs(r.text ,'lxml')
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
client := &http.Client{}
req, err := http.NewRequest("GET", "https://ks-rus.com/catalog/zadvizhki_shibernye/", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:86.0) Gecko/20100101 Firefox/86.0")
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
req.Header.Set("Accept-Language", "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3")
req.Header.Set("Connection", "keep-alive")
req.Header.Set("Referer", "https://ks-rus.com/")
req.Header.Set("Upgrade-Insecure-Requests", "1")
req.Header.Set("TE", "Trailers")
req.Header.Set("Cookie", "BITRIX_SM_SALE_UID=многабукав")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
bodyText, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
curl 'https://ks-rus.com/catalog/zadvizhki_shibernye/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:86.0) Gecko/20100101 Firefox/86.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Connection: keep-alive' -H 'Referer: https://ks-rus.com/' -H 'Cookie: BITRIX_SM_SALE_UID=многабукав' -H 'Upgrade-Insecure-Requests: 1' -H 'TE: Trailers'
Answer the question
In order to leave comments, you need to log in
requests https can't
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question