I'm trying to get correct body of https://www.avito.ru/moskva page with status 200.
req, err := http.NewRequest("GET", "https://www.avito.ru/moskva", nil)
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0")
req.Header.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
client := &http.Client{}
res, err := client.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
fmt.Println(res.Status)
printBody(res) // prints body of page
the output:
403 Forbidden
"security stub from site (says that my ip banned)"
I can open this page in browser without any warnings.
I successfully got body with python:
import requests
session = requests.Session()
session.headers = {
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0',
'Accept-Language': 'ru',
}
print(session.get("https://www.avito.ru/moskva").text)
curl also works well, even without adding any headers:
curl https://www.avito.ru/moskva