我正在尝试使用webdriver抓取AliExpress。
在我滚动他们添加的新滚动按钮后,出现以下错误:
“糟糕...出了点问题。请刷新并重试。(错误:R5UbNq)”
(每当错误的数量改变时)
我该怎么办?
from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
import pyautogui
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
def main():
url = "https://www.aliexpress.com/wholesale?trafficChannel=main&d=y&SearchText=&SortType=default&page=1&switch_new_app=y"
opts = Options()
opts.add_argument("--no-sandbox")
driver = webdriver.Chrome(executable_path="C:/webdrivers/chromedriver")
driver.get(url)
driver.maximize_window()
# Auto Login #
try:
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe#alibaba-login-box[src^='https://passport.aliexpress.com/mini_login.htm?']")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.fm-text#fm-login-id"))).send_keys("BlshBlsh")
driver.find_element_by_css_selector("input.fm-text#fm-login-password").send_keys("BlshBlsh")
driver.find_element_by_css_selector("button.fm-button.fm-submit.password-login").click()
except:
pass
# Auto dragging the mouse #
try:
pyautogui.moveTo(1050, 480)
time.sleep(5)
pyautogui.dragTo(1420, 480, 1.5, button='left')
except:
pass
time.sleep(1000)
if __name__ == "__main__":
main()