編集&は、以下のコードを追加: 私の主な問題は、私は、ファイル1 &ユーザーエージェントファイルでプロキシを持っている2 &私は、同時にそれらの両方を変更していますが、今、私はそれらの両方をプロファイルするためにそれらを送る&ランダムに選択変更したいです.set_preference()でも、1つのプロキシをランダムに選択するだけで、毎回同じプロキシを使用します。誰か助けてくださいどのように私はプロキシを分割し、プロファイルにそれらを送信するユーザーエージェントだけでなく、ランダムなプロキシを選択することができますか?ここでランダムなテキストとループをテキストファイルに挿入して、すべてのテキストをランダムに1つずつ取得する方法はありますか?
def change():
fi = open("C:\\UsersDesktop\\text_file1.txt","r")
file1 = random.choice(fi.readlines())
print(file1)
fi2 = open("C:\\Users\\Desktop\\text_file2.txt","r")
file2 = fi2.read().splitlines()
for p, a in zip(file, file2):
print(p)
IP,PORT = urls.strip().split(':')
print(file1)
try:
print("Trying proxy {0}" .format(p))
print("Brwoser Agent {0}" .format(a))
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", IP)
profile.set_preference("network.proxy.http_port", int(PORT))
profile.set_preference("network.proxy.ssl", IP)
profile.set_preference("network.proxy.ssl_port", int(PORT))
profile.set_preference("network.proxy.ftp", IP)
profile.set_preference("network.proxy.ftp_port", int(PORT))
profile.set_preference("general.useragent.override",'{0}'.format(a))
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
#driver.set_window_position(-2000, 0)
driver.get("https://www.whatismyiaddress.com")
print('Program will pause for 1 min 40 sec')
time.sleep(100)
driver.quit()
except:
print('This is not working : %s' % p)
print("next try in 5 seconds")
time.sleep(5)
driver.quit()
print('Nothing left to try')
コードを投稿する必要があるため、匿名化して投稿することができます。 – quamrana