Find selenium find_element as xpath and use the corresponding variable (?) Is there any way to find the ahref attribute in this? First of all, it doesn't make sense, but for an example of a question, as shown below.?
e = driver.find_element(By.XPATH, '//*[@id="account"]/a')
soup = BeautifulSoup(driver.page_source, 'html.parser')
d = soup.find(e)('a')['href']
Yes, that's how you do it.
from bs4 import BeautifulSoup
html_doc = '<aid="pickme" href="https://example.com">Find me Yes</a>'
soup = BeautifulSoup(html_doc, 'html.parser')
ele = soup.select_one('#pickme')
print(ele['href']) // https://example.com
© 2024 OneMinuteCode. All rights reserved.