我试图在使用Selenium和Python网站报废,我得到了stucked在该网站所谓的“textarea的”领域。这是网站的HTML是如何调用在那里我试图提取文本的区域:硒得到textarea的错误
<textarea class="script" onclick="this.focus();this.select()" readonly="readonly" id="script">
此代码后说到,我想要得到的文本。下面是我使用的代码:
getCode = driver.find_elements_by_tag_name('textarea')
我的问题是,它不承认以下代码文本:
getCode.submit()
getCode.click()
getCode.text()
这是代码错误,我总是得到:
Traceback (most recent call last):
File "ScprL.py", line 55, in module
print (repr(getCode.text))
AttributeError: 'list' object has no attribute 'text'
我会apreciate您的帮助!
如果你想要的第一个文本区域是你想要的文本区域 – Obsidian
,你应该首先像这个'driver.find_elements_by_tag_name('textarea')[0]'从列表中提取webElement想要所有的textarea字段数据 –