python - 如何找到用于scrapy(爬行)的元素iTunes Connect网站?
问题描述
我需要我的应用程序的 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:消息:无法找到元素://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_it
and 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
推荐阅读
- java - 如何添加是或否的重置游戏?游戏Java
- django - 错误:请在 Zappa 设置中定义阶段“create_pg_db”
- php - 为什么在加载 grpc 期间无法找到模块?
- html - 在 Visual Studio 中订购一行 CSS 文件的快速方法
- google-sheets - 价格比较表,突出显示最便宜
- python-3.x - 如何使用 python 将 blob 从 Azure 存储复制到 linux 虚拟机?
- ruby-on-rails - Rails 5:nil类的未定义方法'image'
- r - 计算R中函数乘积的双重积分的问题
- javascript - aframe - 光标组件 - 在最后出现的交叉点而不是第一个交叉点上触发点击事件
- c++ - C++ 新手:尝试从实现中学习单独的接口并得到错误:VSCode 中二进制表达式的操作数无效