[我正在将硒与python一起使用,以在instagram照片中标记照片。
我在this pic中使用以下python代码:
def GetInfosPost(self):
try :
TagsPhoto=self.browser.find_elements_by_class_name('eg3Fv')
except :
TagsPhoto = None
for TagPhoto in TagsPhoto :
print (TagPhoto)
预期输出是:
当前,我有以下输出:
<selenium.webdriver.remote.webelement.WebElement (session="dbab9a8b6ee85103e421bcf12650ccb8", element="ced09e58-511e-401b-8b9f-968c4f7ac311")>
<selenium.webdriver.remote.webelement.WebElement (session="dbab9a8b6ee85103e421bcf12650ccb8", element="c6efc579-10e3-45d8-b05c-2ea28ebf26d9")>
<selenium.webdriver.remote.webelement.WebElement (session="dbab9a8b6ee85103e421bcf12650ccb8", element="0dfce294-f2d0-4644-bc80-a38597c32539")>
<selenium.webdriver.remote.webelement.WebElement (session="dbab9a8b6ee85103e421bcf12650ccb8", element="16820b29-5aaa-4c8c-b088-e10861f680bb")>
<selenium.webdriver.remote.webelement.WebElement (session="dbab9a8b6ee85103e421bcf12650ccb8", element="2ac9ce4c-e135-45c2-b098-fd1f0e7b91ea")>
<selenium.webdriver.remote.webelement.WebElement (session="dbab9a8b6ee85103e421bcf12650ccb8", element="990e20ea-f08a-4510-aaf9-1d08bdc6e9aa")>
如何转换此输出以具有目标输出?
文本值可能被隐藏。请尝试使用TagPhoto.get_attribute("textContent")
for TagPhoto in TagsPhoto :
print (TagPhoto.get_attribute("textContent"))
尝试:
print(TagPhoto.get_attribute("innerText"))