因此,我一直在尝试创建自动化脚本。我有各种Google表单,它们的输入字段数量也不同。
(这些表单不仅限于Google表单,它们可以是任何类型,但它们都带有input
标签)
所以,我想要做的是...
查找在谷歌表单所有输入标签使用beautifulsoup和寻找自己的XPath的可以由硒可以用来在上面点击自动化。
Look at this Google Form for a better overview
import requests
from bs4 import BeautifulSoup
page = requests.get('https://docs.google.com/forms/d/e/1FAIpQLSctPCwcVoji4AyGJOG40PukgBUt1_7XiUuFWxEs4EUXc-YH7g/viewform?usp=sf_link')
soup = BeautifulSoup(page.text, 'html.parser')
input_list = soup.find_all('input')
for input in input_list:
print(input)
输出:
<input aria-describedby="i.desc.921080226 i.err.921080226" aria-label="Q1" autocomplete="off" class="quantumWizTextinputPaperinputInput exportInput" data-initial-dir="auto" data-initial-value="" dir="auto" jsname="YPqjbf" name="entry.1872775733" tabindex="0" type="text" value=""/>
<input aria-describedby="i.desc.1125747839 i.err.1125747839" aria-label="Q2" autocomplete="off" class="quantumWizTextinputPaperinputInput exportInput" data-initial-dir="auto" data-initial-value="" dir="auto" jsname="YPqjbf" name="entry.962306793" tabindex="0" type="text" value=""/>
<input aria-describedby="i.desc.1262061940 i.err.1262061940" aria-label="Q3" autocomplete="off" class="quantumWizTextinputPaperinputInput exportInput" data-initial-dir="auto" data-initial-value="" dir="auto" jsname="YPqjbf" name="entry.330218692" tabindex="0" type="text" value=""/>
<input aria-describedby="i.desc.249579406 i.err.249579406" aria-label="Q4" autocomplete="off" class="quantumWizTextinputPaperinputInput exportInput" data-initial-dir="auto" data-initial-value="" dir="auto" jsname="YPqjbf" name="entry.1162632557" tabindex="0" type="text" value=""/>
<input name="fvv" type="hidden" value="1"/>
<input name="draftResponse" type="hidden" value='[null,null,"-8500811055209088861"]
'/>
<input name="pageHistory" type="hidden" value="0"/>
<input name="fbzx" type="hidden" value="-8500811055209088861"/>
所以,我能够找到输入元素,但如何让自己的XPath,这样我可以使用这些XPath来使用硒填写这些表格?