Откуда вы знаете, что Google может получить ваш фактический IP, когда вы используете прокси? Скорее всего, используемый вами прокси может быть заблокирован Google или тайм-аут получения прокси во время первого подключения.
Чтобы понять эти возможные причины, вы можете написать такой код ->
from torrequest import TorRequest
tr = TorRequest(proxy_port=9050, ctrl_port=9051, password=r"mypassword")
response = tr.get('http://ipecho.net/plain')
proxies = {'http': "socks5://"+response.text+":9050"}
# Using this check, you will know weather your proxies are working or not.
# if proxy for request and current ip are same than proxy is working
try:
print "The proxy for request is {0}".format(response.text)
proxy_check = requests.get('http://icanhazip.com', timeout=60, proxies=proxies)
print "Proxy is {0}".format(proxy_check)
except requests.exceptions.RequestException as e:
print e
# we should catch request exception to check any exception raise from requests like
# timeout
try:
page_response = requests.get('https://www.google.com/search?&q=Apple', timeout=60, verify=False, headers={'User-Agent': random.choice(user_agents)}, proxies=proxies)
except requests.exceptions.RequestException as e:
print e
soup = BeautifulSoup(page_response.content, 'html.parser')
Теперь вы можете знать, какой IP вы используете для доступа к Google. Если прокси работает хорошо, скорее всего, Google уже заблокировал этот прокси.