【问题标题】:User has exceeded the 'max_questions' resource error when accessing Facebook with Selenium on Heroku server在 Heroku 服务器上使用 Selenium 访问 Facebook 时,用户超出了“max_questions”资源错误
【发布时间】:2021-12-25 16:29:50
【问题描述】:

我正在尝试将来自 messenger 的所有消息及其发件人存储在 24/7 运行的数据库中。 下面的代码缩写为ver。整个代码只获取存储在数据库中的发件人以将它们与新的发件人进行比较。

我的问题是:

当我使用本地 chrome 驱动程序执行以下代码时

driver = webdriver.Chrome('/Users/USER/Projects/seleniumBeta/chromedriver 15-24-35-680', chrome_options=chrome_options)

程序成功地从数据库中获取数据。 但是当我用

在heroku上运行以下代码时

heroku 运行 python3 app.py

from sqlalchemy import create_engine, text
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
import os

...

database = create_engine(DB_URL, encoding='utf-8', max_overflow=0)
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"), chrome_options=chrome_options)

globalURL = 'https://www.messenger.com/t/101210925710184'
driver.get(globalURL)   


(... LOGIN CODES)

def repeater():
    senders = [sender['name'] for sender in database.execute(text("SELECT * FROM senders")).fetchall()]
    return repeater()

repeater()

应用无法获取发件人并出现以下错误:

sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1226, "User 'b715fbc9127dd4' has exceeded the 'max_questions' resource (current value: 3600)")

这发生在我允许从本地设备上的 facebook 页面登录未知设备之后。

我很乐意在这里听到任何建议。谢谢!

【问题讨论】:

    标签: python mysql selenium heroku facebook-messenger


    【解决方案1】:

    此错误消息...

    sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1226, "User 'b715fbc9127dd4' has exceeded the 'max_questions' resource (current value: 3600)")
    

    ......意味着主机将每个用户的连接限制为每小时 3600,但您的程序已超过该值。


    解决方案

    您可以尝试以下几个步骤:

    • create_engine()phpmyadmin 内设置以下内容:

      • @MAX_QUESTIONS=0; # 这将设置无限的'max_questions'
      • FLUSH PRIVILEGES;
    • 由于 max_questions 设置为每小时一定数量的请求,您需要在一个小时后重试。

    【讨论】:

    • 谢谢!我将如何使用 max_questions=0 在 create_engine 中传递参数? create_engine('DB_URL', @MAX_QUESTIONS=0) 会吗?还是应该将整个 max 和 flush 的东西作为 sql 脚本执行?
    • 应该可以,否则试试看能否访问phpmyadmin控制台。
    猜你喜欢
    • 1970-01-01
    • 2018-05-12
    • 1970-01-01
    • 2015-10-23
    • 2015-12-13
    • 2020-03-11
    • 1970-01-01
    • 1970-01-01
    • 2013-12-22
    相关资源
    最近更新 更多