Я знаю, что есть много других вопросов по этой проблеме, но они кажутся... устаревшими (?) или, по крайней мере, они больше не работают. Я пробовал несколько методов, таких как ротаторы прокси, пользовательские списки прокси (которых в идеале мне хотелось бы избегать), использование сеансов Tor через Python, но ни один из этих методов не привел меня ни к чему другому, кроме этой ошибки:
--more--
As you were using this website, something about your browser or behaviour made us think you might be a bot.
Solve the captcha below to continue browsing the site.
--more--
По сути, я использую Python для очистки веб-сайта, который предлагает такие объекты, как комнаты, квартиры и т. д. Но я сделал много запросов (и это цель скрипта), и теперь я встретился с упомянутый ответ с помощью капчи.
Важная часть моего кода, которая выполняет запросы и инициализирует сеанс, следующая:
import requests
from bs4 import BeautifulSoup
import csv
from fake_useragent import UserAgent
import random
def init(url):
global session
global proxies
session = requests.Session()
proxies = [
'http://35.185.196.38:3128',
'https://35.185.196.38:3128',
'http://202.86.138.18:8080',
'https://202.86.138.18:8080',
'https://20.206.106.192:80',
'https://20.210.113.32:80',
'https://20.206.106.192:8123',
'https://89.43.31.134:3128',
'https://88.198.212.91:3128',
'http://213.217.30.69:3128',
'https://213.217.30.69:3128',
'https://204.109.59.194:3121',
'https://20.111.54.16:8123',
'https://195.154.184.80:8080',
]
proxy = random.choice(proxies)
print(f"Using proxy: {proxy}")
user_agent = UserAgent()
session.headers.update({'User-Agent': str(user_agent)})
response = session.get('https://[website_url]/')
assert response.status_code == 200
response = session.get('https://[website_url]/cgi-bin/fl/js/verify')
assert response.status_code == 200
try:
response = session.get(url, proxies={'http': proxy, 'https': proxy}, timeout=10)
return response
except requests.exceptions.RequestException as e:
print(f"Request error: {e}")
return None
def scrape_website(url):
response = session.get(url)
if response.status_code == 200:
print(response.text) # Here is where I print the response which contains the captcha response.
-- rest of the code --
Подробнее здесь: https://stackoverflow.com/questions/784 ... ing-python
Как обойти капчу с помощью Python ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как обойти капчу слайдера, чтобы решить головоломку с помощью селена? (Python)
Anonymous » » в форуме Python - 0 Ответы
- 18 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Нажмите кнопку, которая покажет, когда вы разгадали капчу. от Selenium + Python
Anonymous » » в форуме Python - 0 Ответы
- 15 Просмотры
-
Последнее сообщение Anonymous
-