K
K
kakaduwka2020-12-26 14:46:47
Parsing
kakaduwka, 2020-12-26 14:46:47

It doesn't work to make a request to avito, python requests, has anyone come across this?

I can’t make a request to Avito, even with the correct headers, I can’t understand why the content of the response contains the text about the ban by ip

Here is the code:

import requests 

headers={
    'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'Accept-Encoding':'gzip, deflate, br',
    'Accept-Language':'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
    'Cache-Control':'max-age=0, no-cache',
    'Connection':'keep-alive',
    'Cookie':'__cfduid=d98ccf4bc57033e3ce6ea6fb21cb8117e1607062340;__gads=ID=d8ea69ed9b871984-22adea8353b9004c:T=1607062348:S=ALNI_MbLoRO4isOtedH3eHQYGd7_b8HsKw;_fbp=fb.1.1607062347072.2011870276;_ga=GA1.2.598967223.1607062343;_gid=GA1.2.780706771.1608978591;_ym_d=1607062343;_ym_isad=2;_ym_uid=1607062343575335486;_ym_visorc_188382=w;_ym_visorc_34241905=b;_ym_visorc_419506=w;abp=0;buyer_from_page=main;buyer_laas_location=642320;buyer_local_priority_v2=0;buyer_location_id=642320;buyer_popup_location=0;buyer_selected_search_radius4=0_general;cto_bundle=n6uAEV9MTEQlMkIwWFBBUkFoZjNiQXZwUWVIVnJmZHZ0SWtSdWl4STU0OWFtd05BRSUyQnU5NHFnUGhFbHQlMkJoYTVDZE9jMndweUdDcm00ckFrVk5mTm9oc2RlTVRUbDZTNUJmMXNFV1JkU0tSblRKR3VLQ3g1VDBwWU55eDJuT1pQdnhjRXhseU93Z21vclBEcTh4YkZsTk8zdlRpdnclM0QlM0Q;dfp_group=31;f=e8c0af154c5520e62d6059f4e9572c01630247e51b9c7ed6630247e51b9c7ed6630247e51b9c7ed6630247e51b9c7ed6357212485bdbc727357212485bdbc727357212485bdbc72738b4a54cef5443c1d8b16176e03d28734b73d1ecef69802f46b8ae4e81acb9fa1a2a574992f83a9246b8ae4e81acb9fad99271d186dc1cd0e992ad2cc54b8aa82351fe598a5894ec615ab5228c34303140e3fb81381f3591956cdff3d4067aa559b49948619279110df103df0c26013a1d6703cbe432bc2af722fe85c94f7d0c2da10fb74cac1eabdc5322845a0cba1af722fe85c94f7d0c2da10fb74cac1eab2da10fb74cac1eab2da10fb74cac1eab2da10fb74cac1eab3c02ea8f64acc0bd71e7cb57bbcb8e0f868aff1d7654931c9d8e6ff57b051a5874ddae3a7aafbbe4001fae3ab8d7e7b1021dce8db01be7bf7b56bba2e2fa07a5bcfe63ef2ed8e48853bc326cd5f74c8bba0b959aa537dd84ba6354a886a74b5646b8ae4e81acb9fa46b8ae4e81acb9fa02c68186b443a7ac9317cdb1f8e40fc8f2d6e190fd5bbda02da10fb74cac1eab2da10fb74cac1eab3069315ebaf9ae7f8012e98924060d02;lastViewingTime=1607062342126;luri=omsk;no-ssr=1;sessid=8e6abbcda79db35258d93993017bf337.1608978587;showedStoryIds=52-51-50-49-48-47-46-43-41-42-39-32-30;sx=H4sIAAAAAAACA03OQY7CMAxA0bt4zcJJTGp6G0iLAWtqUVMsBvXuAwtG7L+e/hPq2B1L3l0GakYU2NzYTBT6J9yhh9swLQ+PU84WxiLqrvQqBZlEETYwQp8q7rBLidK6AZ7qNOe54MxNKciCxVT5nyxtqfvx9zBsr9yQwijiRVk0R0f5IusWK71JKd2pk2s2YUIzVm2GIf4hfwZN5XE5nM/vO26sGCiBTh6I9k1y4byufz+Gxgr5AAAA;u=2kfjpb8i.udgf3j.uey8i1md3400;v=1608984741',
    'Host':'www.avito.ru',
    'Pragma':'no-cache',
    'Referer':'https://www.avito.ru/omsk',
    'TE':'Trailers',
    'Upgrade-Insecure-Requests':'1',
    'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0'
}

r=requests.get('https://www.avito.ru/omsk/bytovaya_elektronika',headers=headers)
print(r.text)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kakaduwka, 2021-01-16
@kakaduwka

In general, it was just necessary to update the urllib3 and requests libraries, and everything worked :D

D
Dimonchik, 2020-12-26
@dimonchik2013

haha, there are few Avito headers, at least JS must be executed

L
liquiddeath13, 2020-12-26
@liquiddeath13

Most likely you will have to use Selenium or a similar solution

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question