我正在尝试使用Flask在Web上运行Instapy。
我正在尝试使用Flask在Web上运行Instapy。
我有一个Python项目,名为“instapy”,是开源的。我正在尝试使用Flask在Web上运行instapy。它可以正确启动,但在Instagram成功登录后出现错误。\n这是我的代码页面follow.py:\n
from flask import Flask from instapy import InstaPy from instapy.util import smart_run from flask.helpers import get_debug_flag app = Flask(__name__) @app.route("/") def hello(): # 登录凭证 insta_username = '' insta_password = '' # 获取InstaPy会话! # 将headless_browser设置为True以在后台运行InstaPy session = InstaPy(username=insta_username, password=insta_password, nogui=True) with smart_run(session): # 通用设置 session.set_relationship_bounds(enabled=True, delimit_by_numbers=True, max_followers=4590, min_followers=30, min_following=20) # 通用设置 session.set_relationship_bounds(enabled=True, delimit_by_numbers=True, max_followers=4590, min_followers=30, min_following=20) session.set_dont_include(["friend1", "friend2", "friend3"]) session.set_dont_like(["pizza", "#store"]) #_following = session.grab_following(username="", amount="full", live_match=True, store_locally=True) # 行动 #session.like_by_tags([""], amount=500) #session.follow_by_tags([''], amount=1000) #session.follow_user_followers(['', ''], amount=700, randomize=False, sleep_delay=60) #session.follow_likers ([''], photos_grab_amount = 3, follow_likers_per_photo = 150, randomize=True, sleep_delay=600, interact=False) session.unfollow_users(amount=700, nonFollowers=True, style="FIFO", unfollow_after=48*60*60, sleep_delay=300) if __name__ == "__main__": app.run(debug=True)
\n这些错误发生在成功登录后。当Selenium启动时,执行某些事件后程序终止并出现错误。\n我的错误信息:\n
Traceback (most recent call last): File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__ return self.wsgi_app(environ, start_response) File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/Users/erdemnohutcu/InstaPyeski/venv/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/erdemnohutcu/InstaPyeski/unfollowerd.py", line 45, in hello session.set_dont_like(["pizza", "#store"]) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 88, in __exit__ next(self.gen) File "/Users/erdemnohutcu/InstaPyeski/instapy/util.py", line 1435, in smart_run session.end() File "/Users/erdemnohutcu/InstaPyeski/instapy/instapy.py", line 3843, in end with interruption_handler(): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 81, in __enter__ return next(self.gen) File "/Users/erdemnohutcu/InstaPyeski/instapy/util.py", line 880, in interruption_handler original_handler = signal.signal(SIG_type, handler) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/signal.py", line 47, in signal handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler)) ValueError: signal only works in main thread