Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
- from selenium.webdriver.common.proxy import Proxy, ProxyType
- import os
- import random
- import traceback
- import zipfile
- proxy_filename = "proxy_5s.txt"
- if os.path.getsize(proxy_filename):
- _proxy_list_file = list(filter(None, (line.rstrip() for line in open(proxy_filename))))
- PROXY = random.choice(_proxy_list_file)
- PROXY = ":".join([PROXY.split(':')[0], PROXY.split(':')[1]])
- auth = "paulohot12749:h4h3p9ppv5"
- capabilities = DesiredCapabilities.CHROME.copy()
- chromeOptionsRemote = webdriver.ChromeOptions()
- chromeOptionsRemote.add_argument("--start-maximized")
- chromeOptionsRemote.add_argument("--disable-session-crashed-bubble")
- chromeOptionsRemote.add_argument("--ignore-ssl-errors=true")
- chromeOptionsRemote.add_argument("--ssl-protocol=all")
- # chromeOptionsRemote.add_argument("--proxy-server=https://{}".format(PROXY))
- # chromeOptionsRemote.add_argument("--proxy-auth={}".format(auth))
- manifest_json = """
- {
- "version": "1.0.0",
- "manifest_version": 2,
- "name": "Chrome Proxy",
- "permissions": [
- "proxy",
- "tabs",
- "unlimitedStorage",
- "storage",
- "<all_urls>",
- "webRequest",
- "webRequestBlocking"
- ],
- "background": {
- "scripts": ["background.js"]
- },
- "minimum_chrome_version":"22.0.0"
- }
- """
- background_js = """
- var config = {
- mode: "fixed_servers",
- rules: {
- singleProxy: {
- scheme: "http",
- host: "%s",
- port: parseInt(%s)
- },
- bypassList: ["localhost"]
- }
- };
- chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
- function callbackFn(details) {
- return {
- authCredentials: {
- username: "%s",
- password: "%s"
- }
- };
- }
- chrome.webRequest.onAuthRequired.addListener(
- callbackFn,
- {urls: ["<all_urls>"]},
- ['blocking']
- );
- """ % (PROXY.split(':')[0], PROXY.split(':')[1], auth.split(':')[0], auth.split(':')[1])
- # driver = None
- try:
- pluginfile = 'proxy_auth_plugin.zip'
- with zipfile.ZipFile(pluginfile, 'w') as zp:
- zp.writestr("manifest.json", manifest_json)
- zp.writestr("background.js", background_js)
- chromeOptionsRemote.add_extension(pluginfile)
- chromeOptionsRemote.add_extension('easy_webrtc.crx')
- driver = webdriver.Remote(options=chromeOptionsRemote, command_executor='http://78.31.71.191:4444/wd/hub',
- desired_capabilities=capabilities)
- driver.set_page_load_timeout(30)
- driver.implicitly_wait(15)
- driver.get('https://www.whoer.net/')
- driver.save_screenshot(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'screen.png'))
- print(driver.current_url)
- driver.execute_script("window.scrollTo(0, 600);")
- driver.save_screenshot(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'screen2.png'))
- ip_elem = driver.find_element_by_xpath("//strong[@data-clipboard-target]")
- print(ip_elem.text)
- except Exception as e:
- traceback.print_exc()
- driver.save_screenshot(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'screen1.png'))
- finally:
- driver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement