我正在使用 InstaPy 为 Instagram 编写一个机器人。我需要很多帐户,所以我使用线程,但出现错误:
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Program Files\Python\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Program Files\Python\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\User\Desktop\inst\inst.py", line 99, in follow_by_list
user_session = InstaPy(username=user.name,
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\instapy.py", line
327, in __init__
self.browser, err_msg = set_selenium_local_session(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\browser.py", line
123, in set_selenium_local_session
browser = webdriver.Firefox(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-
packages\selenium\webdriver\firefox\webdriver.py", line 174, in __init__
self.service.start()
File "C:\Users\User\AppData\Roaming\Python\Python39\site-
packages\selenium\webdriver\common\service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Program Files\Python\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\Python\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 193] %1 �� �������� ����������� Win32
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Program Files\Python\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Program Files\Python\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\User\Desktop\inst\inst.py", line 99, in follow_by_list
user_session = InstaPy(username=user.name,
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\instapy.py", line
327, in __init__
self.browser, err_msg = set_selenium_local_session(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\browser.py", line
122, in set_selenium_local_session
driver_path = geckodriver_path or get_geckodriver()
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\browser.py", line
38, in get_geckodriver
sym_path = gdd.download_and_install()[1]
File "C:\Users\User\AppData\Roaming\Python\Python39\site-
packages\webdriverdownloader\webdriverdownloader.py", line 225, in download_and_install
shutil.copy2(src_file, dest_file)
File "C:\Program Files\Python\lib\shutil.py", line 435, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Program Files\Python\lib\shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied:
'C:\\Users\\User\\InstaPy\\assets\\geckodriver.exe'
代码:
class User
#...
def run():
following = ["user1", "user2"]
threads = []
for user in user_accs:
t = Thread(target=Giv.follow_by_list, args=(user, following,), group=None)
threads.append(t)
t.start()
for t in threads:
t.join()
def follow_by_list(user, following):
user_session = InstaPy(username=user.name,
password=user.password,
proxy_username=user.proxy_username,
proxy_password=user.proxy_password,
proxy_address=user.proxy_address,
proxy_port=int(user.proxy_port))
user_session.login()
user_session.follow_by_list(followlist=following, times=1, interact=False)
user_session.end(threaded_session=True)
def main():
run()
if __name__ == "__main__":
main()
如果我调用一个帐户的代码,一切正常:
#...
for user in user_accs:
t = Thread(target=Giv.follow_by_list, args=(user, following,), group=None)
threads.append(t)
t.start()
break # for one account
#...