代码有效,但不是我想要它起作用。
仅更改远程端口。 User_agent我在这里使用https://github.com/sqlmapproject/sqlmap/blob/master/txt/user-agents.txt
任何帮助我都会有所帮助。是不是我的互联网提供商不允许改变?
这是代码:
import random, time, requests
from selenium import webdriver
from selenium.webdriver.common.proxy import *
from bs4 import BeautifulSoup
USER_AGENTS_FILE = './user_agents.txt'
RUNNING = True
def LoadUserAgents(uafile=USER_AGENTS_FILE):
uas = []
with open(uafile, 'r') as uaf:
for ua in uaf.readlines():
if ua:
uas.append(ua.strip() [0:-1-1])
random.shuffle(uas)
return uas
uas = LoadUserAgents()
while RUNNING == True:
profile = webdriver.FirefoxProfile()
profile.set_preference('general.usragent.override', random.choice(uas))
driver = webdriver.Firefox(firefox_profile=profile)
driver.get('http://www.ipchicken.com/')
input('Press enter to continue')
driver.quit()