微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用python硒驱动程序下载pdf文件

如何解决使用python硒驱动程序下载pdf文件

我正在尝试从链接steel下载pdf文件(“下载产品目录”)。使用python xpath实现此目的。但出现语法错误。尝试了所有排列和组合。我尝试过的代码如下:

    import time
    from selenium import webdriver
    driver = webdriver.Chrome('c:/windows/chromedriver.exe')  # Optional argument,if not specified will search path.
    driver.get("https://sail.co.in/en/products/sail-structural-sections")
    time.sleep(5) # Let the user actually see something!
    elem =driver.find_element_by_xpath('//a[text()='Download Product Catalogue']//parent::div[@class='toppdf_brochure pdfbrochure']')
    elem.click()
    time.sleep(5) # Let the user actually see something!
    driver.quit()

解决方法

尝试以下/authenticate

xpath

完整代码:

elem =driver.find_element_by_xpath("//*[contains(text(),'Download Product Catalogue')]")

浏览器屏幕截图:

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。