【问题标题】:My Tinder bot won't stop autoswiping right [closed]我的 Tinder 机器人不会停止向右自动滑动 [关闭]
【发布时间】:2020-09-18 23:56:39
【问题描述】:

我想避免机器人检测并且我的随机东西不起作用。实际上,它根本不是不喜欢的。 Xpaths 没问题。我在这里做错了什么?

def auto_swipe(self):
    while True:
        sleep_time = random.randrange(1, 3)
        time.sleep(sleep_time)
        try:
            rand1 = random.randrange(0,100)
            if rand1 < random.randrange(70,80):
                self.like()
            else:
                self.dislike()
        except Exception:
            try:
                self.close_popup()
            except Exception:
                self.close_match()

【问题讨论】:

  • 这听起来像X-Y problem。与其寻求解决问题的帮助,不如编辑您的问题并询问实际问题。你想做什么?

标签: python python-2.7 selenium


【解决方案1】:

random 的标准使用方式如下。假设您希望某件事在 75% 的时间内发生,您将编写以下内容:

if random.random() < 0.75:
   # do something

【讨论】:

  • 我不能投票,但就是这样。谢谢!
  • 上下文中的解决方案 try: rand = random() if rand
猜你喜欢
  • 2020-11-10
  • 1970-01-01
  • 2021-10-24
  • 1970-01-01
  • 1970-01-01
  • 2013-07-05
  • 1970-01-01
  • 1970-01-01
  • 2012-08-10
相关资源
最近更新 更多