I've written a script in python in combination with selenium to fetch a text block from a webpage in which it is written that my scraper is sending request via proxy or not.
For example: if the request is not sent via proxy then text should appear in the console is like 'This request appears NOT to have come via a proxy.', 'The request appears to have originated from ip address [my_ip_address]' which is what I'm having.
How can I run my scraper through proxy? Thanks in advance.
Script I've tried with:
from selenium import webdriver
proxies = {
'http': 'http://163.172.27.213:3128',
'https': 'https://163.172.175.210:3128'
}
chrome_options = webdriver.ChromeOptions()
proxy_arg = ';'.join(['{}={}'.format(k, v) for k, v in proxies.items()])
chrome_options.add_argument('--proxy-server="{}"'.format(proxy_arg))
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('http://www.lagado.com/proxy-test')
items = [item.text for item in driver.find_elements_by_css_selector(".main-panel p")[:2]]
print(items)
driver.quit()