[英]how to use Python script (selenium) to extract data from excel sheet and input into website
I was wondering how I would be able to get rows data from an excel spreadsheet and input it into text boxes on a cms using selenium.我想知道如何从 excel 电子表格中获取行数据并将其输入到使用 selenium 的 cms 上的文本框中。 I was confused on how i would enter 1 row of data into 1 text box and the next row of data into the next text box.我对如何将 1 行数据输入 1 个文本框并将下一行数据输入下一个文本框感到困惑。
if someone would be kind of enough to help, that would be amazing.如果有人能提供足够的帮助,那就太棒了。
thank you谢谢你
you can use pandas to read an excel file and Keys from the Keys class in selenium.您可以使用 Pandas 从 selenium 中的 Keys 类中读取 Excel 文件和 Keys。
this has a list of functions you can pass to interact with the browser with their unicode(? might be wrong) equivilent.这有一个函数列表,您可以通过它们的 unicode(?可能是错误的)等效传递与浏览器交互的函数。
class Keys(object):
"""
Set of special keys codes.
"""
NULL = '\ue000'
CANCEL = '\ue001' # ^break
HELP = '\ue002'
BACKSPACE = '\ue003'
import pandas as pd
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
df = pd.read_excel(your_excel_file)
driver = webdriver.Chrome(your_driver)
### do stuff
data = df[your_data_col][0] # grabbing one value, you'll probably need to iterate using a loop.
driver.find_element_by_xpath(your_xpath).send_keys(data)
# do more stuff.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.