Хочу сделать запрос к
https://detmir.ru через прокси, но получаю в ответ response 418, подставлял куки из бразура, тоже не помогло. Вот вывод с помощью print(r, r.text)
import requests
from bs4 import BeautifulSoup
url = 'https://detmir.ru'
with open('proxies.txt', 'r') as f:
proxies = [line.strip() for line in f]
headers = {
'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.7',
'accept-language': 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
'priority': 'u=0, i',
'referer': 'https://www.detmir.ru/',
'sec-ch-ua': '"Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'same-origin',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36',
}
for i in proxies:
r = requests.get(url, proxies={
'http': f'http://{i}', 'https': f'http://{i}'
}, headers=headers)
soup = BeautifulSoup(r.text, 'lxml')
ip = soup.find('div', class_='ip')
print(r, i)