selenium python查找输出到pandas的元素



新来的。

需要Selenium Python, Find Elements, Pandas:的帮助

如下:

array=[]
array=driver.find_elements_by_xpath("//fl-list-item")
for e in array:
print(e.text)

我可以看到打印(e.m ext)如下:(有20个元素,这是第一个)

Convert a PDF in Word
$250 – 750 USD
Posted 6 minutes ago
We would like to have a (scanned) PDF file convert to a Word file
Data Entry
Excel
PDF
Word
Copy Typing
Fixed Price
28 Bids
0.0

问题:我如何得到这些作为一行与标题使用熊猫?

看了很多视频,也知道了一些零碎的东西,但还是不能把数据输入Pandas。

感谢对新手的帮助。

根据我的理解,您希望将每个数组项存储在单独的列中,并在for循环中为其提供标题。你可以这样做:

import pandas as pd
# create a dataframe with correct shape
df = pd.DataFrame({'index':['placeholder']})
# your array here
array = ['first','second','third','fourth']
# create an index for column headers
index = 1
# iterate through your array and set each column value
for item in array:
df[index] = item
index += 1
print(df.head())

输出:

index      1       2      3       4
0  placeholder  first  second  third  fourth

最新更新