ADD get fileattribute, file basename

This commit is contained in:
Thomas Kuschel 2024-06-15 23:40:34 +02:00
parent 656ed78288
commit a479e1586f

View File

@ -44,27 +44,31 @@ def call_website(url,interactive=False):
driver.get(url)
print(driver.title)
elements = driver.find_elements(By.XPATH,'//a[contains(@href,"Rufzeichen")]')
# elements = driver.find_elements(By.XPATH,'//a[contains(@href,"Rufzeichen")]')
elements = driver.find_elements(By.PARTIAL_LINK_TEXT,"Rufzeichen")
if elements:
element = elements[0]
filename = element.click()
href = element.get_attribute('href')
filename = element.click() # take the first one
else:
print('Sorry, no Link containing "Rufzeichen" found.')
driver.close()
sys.exit(2)
print(element.text)
print()
# print(href)
time.sleep(5)
driver.close()
return os.path.basename(href)
if __name__ == '__main__':
# call_description()
args = call_parser()
try:
filename = call_website(**vars(args))
print(f'File name: {filename}')
sys.exit(0)
except Exception as e:
print('Error: {}'.format(e), file=sys.stderr)