如何找到元素iTunes Connect网站进行抓取(抓取)?



我需要我的应用程序的CFBundle版本,所以我尝试了刮擦的iTunes Connect网站,但我无法获得元素。

我试过了:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://appstoreconnect.apple.com/login")
elem = driver.find_element_by_xpath("//input[@id='account_name_text_field']")

我收到以下错误:

elenium.common.exceptions.NoSuchElementException: 消息: 无法 定位元素://input[@id='account_name_text_field']

我认为该网站是不同的结构... 我该怎么办?

你的定位器没有错:

driver.find_element_by_xpath("//input[@id='account_name_text_field']")

它在iframe里面,需要先开关,用frame_to_be_available_and_switch_to_itvisibility_of_element_located,像这样:

driver.get('https://appstoreconnect.apple.com/login')
WebDriverWait(driver, 30).until(expected_conditions.frame_to_be_available_and_switch_to_it((By.ID, "aid-auth-widget-iFrame")))
WebDriverWait(driver, 30).until(expected_conditions.visibility_of_element_located((By.XPATH, "//input[@id='account_name_text_field']")))
elem = driver.find_element_by_xpath("//input[@id='account_name_text_field']")
elem.send_keys("userName")

以下导入:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions

最新更新