Есть парсер, который работает корректно при запуске на компьютере в pycharm и всегда выдает код ответа 200. Я загрузил его на VPS. При запуске на VPS, я получаю код ответа 403.
вот код парсера
import ssl
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
from requests.packages.urllib3.util import ssl_
CIPHERS = """ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:AES256-SHA"""
class TlsAdapter(HTTPAdapter):
def __init__(self, ssl_options=0, **kwargs):
self.ssl_options = ssl_options
super(TlsAdapter, self).__init__(**kwargs)
def init_poolmanager(self, *pool_args, **pool_kwargs):
ctx = ssl_.create_urllib3_context(ciphers=CIPHERS, cert_reqs=ssl.CERT_REQUIRED, options=self.ssl_options)
self.poolmanager = PoolManager(*pool_args, ssl_context=ctx, **pool_kwargs)
def start_parse():
s = rq.Session()
adapter = TlsAdapter(ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1)
s.mount("https://", adapter)
headers = {
'Cookie': 'u=2k0nw16y.q420lk.gchwt1phqb; buyer_local_priority_v2=0; auth=1; _ym_uid=1583305579738920477; _ym_d=1659474667; _gcl_au=1.1.306360019.1659474668; tmr_lvid=ab66799de9d8d160817d2764d6215b7c; tmr_lvidTS=1659474668340; adrcid=AqA7iNrg2hyd8a-AJsUe62w; uxs_uid=09ba2d90-12aa-11ed-8b39-23eadce0d1ae; buyer_laas_location=658080; v=1664286461; luri=tula; buyer_location_id=658080; sx=H4sIAAAAAAAC/wTAQQ6CMBAF0Lv8tQvbjtOht5mGP+pGEzAEJL0774SJ15lB1kL2XLp6qMZdXB5JXNBObGg4yj8dnPaFW83rc54+sX77br9kr7cuuIFoSVVKzaZ5jCsAAP//dI0B0lsAAAA=; dfp_group=76; SEARCH_HISTORY_IDS=1,4; _ym_isad=2; _ym_visorc=b; cto_bundle=lmLLAF9mRXlEb0VEa1RCbVZwM20wUyUyQktsd1MlMkZKJTJCemJ0bEppRWlDMDF4Q0pvUmhmRExjR1pwdnIwSHdrMU54M2ttek0lMkZtJTJGZ0ZiaGFCMzRra3M0dHIlMkZYRmslMkZwRndabWNKWWl0VjZWOVY0R2NPN2lRJTJGakg1bmtkZ2dudFBtMnJRbGJwOWFNZkc3QzM1Q2RaME53TzBtbllaYmszT25Ya1F6ZyUyQkZVWW5WaVE5dHdjYXZCYmFPbnBZRmpucXZQRE5jNnBMZE8; buyer_from_page=catalog; _buzz_fpc=JTdCJTIycGF0aCUyMiUzQSUyMiUyRiUyMiUyQyUyMmRvbWFpbiUyMiUzQSUyMi53d3cuYXZpdG8ucnUlMjIlMkMlMjJleHBpcmVzJTIyJTNBJTIyV2VkJTJDJTIwMjclMjBTZXAlMjAyMDIzJTIwMTMlM0E0NyUzQTQ5JTIwR01UJTIyJTJDJTIyU2FtZVNpdGUlMjIlM0ElMjJMYXglMjIlMkMlMjJ2YWx1ZSUyMiUzQSUyMiU3QiU1QyUyMnZhbHVlJTVDJTIyJTNBJTVDJTIyMjg0ZGUxMWY1Mjc5MTc5NjgxOWM0ODk4MTU2ZjkwMTIlNUMlMjIlMkMlNUMlMjJmcGpzRm9ybWF0JTVDJTIyJTNBdHJ1ZSU3RCUyMiU3RA==; tmr_detect=0|1664286470115; f=5.cc913c231fb04ceddc134d8a1938bf88a68643d4d8df96e9a68643d4d8df96e9a68643d4d8df96e9a68643d4d8df96e94f9572e6986d0c624f9572e6986d0c624f9572e6986d0c62ba029cd346349f36c1e8912fd5a48d02c1e8912fd5a48d0246b8ae4e81acb9fa143114829cf33ca746b8ae4e81acb9fa46b8ae4e81acb9fae992ad2cc54b8aa8af305aadb1df8cebc93bf74210ee38d940e3fb81381f359178ba5f931b08c66a59b49948619279110df103df0c26013a2ebf3cb6fd35a0acdc5322845a0cba1af0c77052689da50ddc5322845a0cba1aba0ac8037e2b74f92da10fb74cac1eab2da10fb74cac1eab71e7cb57bbcb8e0f8b1472fe2f9ba6b90df103df0c26013a037e1fbb3ea05095de87ad3b397f946b4c41e97fe93686ad7dafaee455a8022c9d5e06f6308706fd5d3d12014bda85a4cf1456ec441ab74db39c22f850ff212f29aa4cecca288d6b5902567352896504ef4042d06704780046b8ae4e81acb9fa46b8ae4e81acb9fa02c68186b443a7ac4c51f6e36372136372eb1df193e939d72da10fb74cac1eab2da10fb74cac1eabe61a31fbb5a8928c77a808498cdf8f208012e98924060d02; isCriteoSetNew=true; ft="2N4VKhT2c1tkgyGJxigk4JoPyht9wA1srsjE5ksmCXidTW9NssMtueRNoyghPcv5MF2ElubX8rEThWdqb6ioIVNPKonZ0e6YmrQvIZ/iHPHBcHdOH8tTx7xA1j9Yju/VnV9jRNfg+qUdjzEzFjev2XhkP1JIp4Jq02csly4JXUCuXu1bqZkNrLJFLaCqnLCv"; __zzatw-avito=MDA0dBA=Fz2+aQ==; __zzatw-avito=MDA0dBA=Fz2+aQ==; gssc213181=; cfidsw-avito=lpfOQ4yoggP8rP+Xw8H3gpE91f7SgXF/8ZQNFAfbtOJ0X6d35U5JjNOt5qpb3Jz+zGjnhUbFlv3AvTLOgx1x8jSvSwMwE0AnI1mp37t+tmq3qOcqype1aUAc7t9rcDSFPyqm3GkJeZIGsqqneeG2vxF+L++PyYdQmkSD; cfidsw-avito=lpfOQ4yoggP8rP+Xw8H3gpE91f7SgXF/8ZQNFAfbtOJ0X6d35U5JjNOt5qpb3Jz+zGjnhUbFlv3AvTLOgx1x8jSvSwMwE0AnI1mp37t+tmq3qOcqype1aUAc7t9rcDSFPyqm3GkJeZIGsqqneeG2vxF+L++PyYdQmkSD; cfidsw-avito=lpfOQ4yoggP8rP+Xw8H3gpE91f7SgXF/8ZQNFAfbtOJ0X6d35U5JjNOt5qpb3Jz+zGjnhUbFlv3AvTLOgx1x8jSvSwMwE0AnI1mp37t+tmq3qOcqype1aUAc7t9rcDSFPyqm3GkJeZIGsqqneeG2vxF+L++PyYdQmkSD; gsscw-avito=4aLpVDC55HgglMzS3inLKOA/PDB3so6zPMZGfOy8O9fG5/57f1KtOAU/h95kewzk2Gd43quA+dkvwnXRXSfppKsNZEW441vj50v4f4y/y3uQ+dIXPGbhC/YGrl3UTv6qCjkqhNf/SRrpwbJVUZo0ycchLrwdiHnnBtYomMhqm9QwsETajLGdb3ihx9SP5IFYxOdRQ3xM9qKQi6KkbzrNdhOvILIIq5tlBhMBvDEHAwCk22ej8sKAdJChzelIJQ==; gsscw-avito=4aLpVDC55HgglMzS3inLKOA/PDB3so6zPMZGfOy8O9fG5/57f1KtOAU/h95kewzk2Gd43quA+dkvwnXRXSfppKsNZEW441vj50v4f4y/y3uQ+dIXPGbhC/YGrl3UTv6qCjkqhNf/SRrpwbJVUZo0ycchLrwdiHnnBtYomMhqm9QwsETajLGdb3ihx9SP5IFYxOdRQ3xM9qKQi6KkbzrNdhOvILIIq5tlBhMBvDEHAwCk22ej8sKAdJChzelIJQ==; abp=0; _ga_M29JC28873=GS1.1.1664286467.18.1.1664286656.60.0.0; _ga_9E363E7BES=GS1.1.1664286467.21.1.1664286656.60.0.0; _ga=GA1.2.91064731.1583305580; _gid=GA1.2.763985877.1664286657; _dc_gtm_UA-2546784-1=1; sessid=f965f59f42a8bd85b3dffb43623f8f25.1664286656; tmr_reqNum=208; fgsscw-avito=Sh1o360977e5124aeec39d361bfd574cde734b5f; fgsscw-avito=Sh1o360977e5124aeec39d361bfd574cde734b5f',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
'Accept-Language': 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive'
}
r = s.request('GET', f'https://site.ru', headers=headers)