我正在尝试使用烧瓶在网络上运行instapy

时间:2018-12-27 01:04:04

标签: python selenium flask

我有开放源代码“ instapy”的python项目。我试图用烧瓶在网络上运行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)

成功登录后出现的这些错误。当硒开始时,执行一些事件程序会结束,并且会出现错误。 我的错误:

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

0 个答案:

没有答案
相关问题