5

I am trying to interact with Hola the VPN connection as a chrome extension through selenium. It is read in and the browser renders with the chrome extension, however I want to make a get request to netflix and store all of the IP's. How can I make a get request and use Hola to change my IP for every country on the list?

Thanks.

from browsermobproxy import Server
import os, pdb
from selenium import webdriver


def bootServer():
    server = Server("/Users/Desktop/browsermob-proxy-2.1.2/bin/browsermob-proxy")
    server.start()
    proxy = server.create_proxy()
    return proxy, server


def bootDriver(proxy):
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_extension('/Users/Desktop/extension.crx')
    chrome_options.add_argument("--proxy-server={0}".format(proxy.proxy))
    driver = webdriver.Chrome(chrome_options = chrome_options, executable_path = os.getcwd() + "/chromedriver")
    return driver 

def getCountryCodes():
    data = []
    with open("countryCodes.txt") as f:
        content = f.readlines()
        for cc in content:
            data.append(cc.strip())
    return data 

def main():
    proxy, server = bootServer()
    proxy.new_har("netflix")
    driver = bootDriver(proxy)
    countryCodes = getCountryCodes()
    for cc in countryCodes:
        pdb.set_trace()
        driver.get("https://www.netflix.com/watch/80028554?trackId=14170082&tctx=0%2C0%2C8c294fdd-6462-4eae-abd7-6d519143971e-2851377")
        proxy.new_page("netflix")

    ips = [dat['serverIPAddress'] for dat in proxy.har['log']['entries']]
    pdb.set_trace()
    server.stop()
    driver.quit()

main()

0 Answers0