简体   繁体   English

如何使用Python脚本(selenium)从excel表中提取数据并输入到网站

[英]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.

相关问题 如何使用 Python 提取 Excel 表数据 - How to use Python to extract Excel Sheet data 如何使用硒从网站中提取数据? - How to extract data with selenium from a website? 如何使用python将excel中提取的数据输入到网站中? - How to input extracted data from excel into a website using python? For循环使用python从硒中的Excel工作表中读取数据 - For loop to read data from excel sheet in selenium using python 如何使用 python 从 excel 中提取条件数据 - how to use python to extract conditional data from excel 我如何使用python和beautifulsoup从嵌入html的Excel工作表中提取数据? - How can i extract data from an excel sheet embedded in html using python and beautifulsoup? 如何使用python从Excel工作表中提取超链接单元格 - How to extract the hyperlink cell from excel sheet using python 如何将从Excel工作表提取的数据框中的所有数据传递到highchart? - How to pass all the data in dataframe that extract from excel sheet to highchart? 如何在python中使用硒从网站提取openload链接 - how to extract openload link from a website using selenium in python 如何使用 python、selenium 和 chromedriver 从网站中提取此值 - how can i extract this value from a website, with python, selenium and chromedriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM