我试图用python和selenium编写一个自动程序来创建自动Instagram帐户。我添加了所有安全选项,甚至Instagram也阻止我创建新帐户。
我确实尝试了一切。清理cookie,捕获,隐身模式,代理,禁用位置,使用伪造的标题,最后我尝试了新的Internet连接(智能手机的热点)。但是Instagram仍然阻止我。如何修改我的代码以防止将Instagram我检测为我?
InstaAction类仅调用storage.clear()
class MyInstaAction(webdriver.Chrome):
def __init__(self, *args, **kwargs):
super().__init__('chromedriver.exe', *args, **kwargs)
def root(self):
self.get(mpaths.root)
def create_account(self, user):
self.get(mpaths.register)
self.execute_script('localStorage.clear();')
# Finding elements and doing other stuff
“主要”安全设置
if mconf.use_proxy:
proxies = my_proxys.get_proxys()
if count > len(proxies):
print(f'Only {len(proxies)} available\n'
f'Setting counter to maximum of {len(proxies)}')
count = len(proxies)
else:
proxies = [0 for _ in range(count)]
for i, proxy in zip(range(count), proxies):
try:
user = MyUserFactory.get_user()
if doc.does_user_exist(user):
same += 1
continue
opt = webdriver.ChromeOptions()
opt.add_argument("disable-infobars")
opt.add_argument("--incognito")
prefs = {"profile.default_content_setting_values.geolocation": 2}
opt.add_experimental_option("prefs", prefs)
ua = rua.random
print(ua)
opt.add_argument(f"user-agent={ua}")
opt.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
if proxy:
# Setting up proxy package
opt.add_argument('--proxy-server=%s' % proxy)
# end
iact = MyInstaAction(options=opt)
iact.delete_all_cookies()
有人可以解决这个问题吗?
答案 0 :(得分:0)
尝试更改用户代理。
options.add_argument("user-agent=YOUR_DEVICE")