【问题标题】:How to find element iTunes Connect website for scrapy(crawling)?如何找到用于scrapy(爬行)的元素iTunes Connect网站?
【发布时间】:2019-09-02 07:19:47
【问题描述】:

我需要我的应用程序的 CFBundleversion,所以我尝试了 scrapy 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:消息:无法 定位元素://输入[@id='account_name_text_field']

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

【问题讨论】:

  • 你遇到了什么错误?
  • selenium.common.exceptions.NoSuchElementException:消息:无法找到元素://input[@id='account_name_text_field']
  • @ItamarMushkin driver.page_source 的结果与浏览器视图源不同我不知道为什么不同的结果
  • 请将这些内容编辑到问题正文中,而不仅仅是在 cmets 中

标签: python selenium scrapy web-crawler


【解决方案1】:

你的定位器没有问题:

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

在iframe里面,需要先切换,使用frame_to_be_available_and_switch_to_it和visibility_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

【讨论】:

    猜你喜欢
    • 2018-05-05
    • 2021-12-28
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多