json_obj=json.loads(json_string.replace('true','True').replace('false','False'))
proxies = [
{"http": "1.1.1.1"},
{"http": "2.2.2.2"}
]
for url in list_urls:
ip=proxies[0] # берём первый прокси из списка
proxies.pop(0) # Убираем его из списка
proxies.append(ip) # Добавляем его в конец списка для повторного использования
page=requests.get(url, proxies=ip)
...
from lxml import html
...
code=driver.page_source
tree=html.fromstring(code)
el=tree.xpath("//a[contains(@href,'marketgid')]")
if len(el)>0:
elem=driver.find_element_by_xpath("//a[contains(@href,'marketgid')]").click()
else:
....
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
webdriver.DesiredCapabilities.PHANTOMJS['proxy']={"httpProxy":'94.20.21.38:3128', "proxyType":"MANUAL"}
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=DesiredCapabilities.PHANTOMJS)
driver.get('https://www.iplocation.net/')
x=driver.find_element_by_xpath('//p[contains(text(),"Your public IP Address is")]')
if x is not None: print x.text
session=requests.Session()
session.cookies.clear()
session.keep_alive = False
session.headers = {'Connection':'close', 'User-Agent': agent} #agent - random
page=session.get(url, proxies={'http':'http://'+IP}, timeout=(60,60)) # IP - rotation
session.cookies.clear()