问题
I'm trying to get all the content under Signers, Counter Signers and X509 Signers from https://www.virustotal.com/gui/file/03d1316407796b32c03f17f819cca5bede2b0504ecdb7ba3b845c1ed618ae934/details
from selenium import webdriver
op = webdriver.ChromeOptions()
op.add_argument('headless')
driver = webdriver.Chrome(executable_path="/Desktop/chromedriver", options=op)
details_url = "https://www.virustotal.com/gui/file/03d1316407796b32c03f17f819cca5bede2b0504ecdb7ba3b845c1ed618ae934/details"
driver.get(details_url)
element = driver.find_element_by_xpath("/html/body/vt-ui-shell")
print(element.text)
The result doesn't include the parts under Signers, Counter Signers and X509 Signers

So, in order to get those parts, I tried shadowRoot.querySelector().
However it didn't give me everything I need.
i.e. When I tried to get this part
by doing
print(driver.execute_script("return document.querySelector('file-view').shadowRoot.querySelector('vt-ui-file-details').shadowRoot.querySelector('vt-ui-signature-info').shadowRoot.querySelector('vt-ui-expandable-detail.signer-info').querySelector('span').querySelector('vt-ui-key-val-table').shadowRoot.querySelector('div.row').querySelector('div.value').querySelector('div > div > div:nth-child(1) > div > a:nth-child(2)')").text)
it printed nothing.
Please help! Thanks in advance
回答1:
If you want the microsoft time
elem=driver.execute_script("return document.querySelector('file-view').shadowRoot.querySelector('vt-ui-file-details').shadowRoot.querySelector('vt-ui-signature-info').shadowRoot.querySelector('vt-ui-expandable-detail.signer-info').querySelector('span').querySelector('vt-ui-key-val-table').shadowRoot.querySelector('div.row').querySelector('div.value').querySelector('div > div > div:nth-child(1) > div > a:nth-child(2)')")
print(elem.get_attribute('textContent'))
来源:https://stackoverflow.com/questions/65462625/cant-locate-specific-elements-using-python-selenium-and-shadowroot-queryselecto