python - 我正在尝试使用烧瓶在网络上运行 instapy
问题描述
我有 python 项目,它是开源的'instapy'。我正在尝试使用烧瓶在网络上运行 instapy。它开始正确,但在 instagram 成功登录后。我有错误。
这是我的代码页 follow.py
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():
# login credentials
insta_username = ''
insta_password = ''
# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username,
password=insta_password,
nogui=True)
with smart_run(session):
# general settings
session.set_relationship_bounds(enabled=True,
delimit_by_numbers=True,
max_followers=4590,
min_followers=30,
min_following=20)
# general settings
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)
# activity
#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)
成功登录后出现这些错误。当 selenium 启动时,做一些事件程序结束并且我得到错误。我的错误:
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
解决方案
推荐阅读
- javascript - 使用 Angular JS 生成动态 HTML id
- asp.net - 在 Visual Basic 中在 2 行上显示字符串
- java - 如何使用时间戳字段按天对实体列表进行分组?
- javascript - 任何证明微任务在渲染之前执行的示例?
- javascript - Uncaught SyntaxError: Missing ) 在参数列表之后,但没有额外的}?
- python - 为什么 py 和 python 给出不同的结果?
- php - PHP 或 HTML 或 CSS 图像从原始最大高度 100 缩放,但将宽度缩放为自动;
- c# - ASP.NET Core 3.1 和 Entity Framework Core:一对多的关系
- javascript - 如何以智能和干净的方式使用文件系统
- xaml - 如何将 Observable Collection 的整个元素绑定到 Xamarin Forms 中的 ContentView