【问题标题】:Python Selenium Beautifulsoup pdfPython Selenium Beautifulsoup pdf
【发布时间】:2020-10-03 19:07:46
【问题描述】:

我正在尝试制作一个在完成搜索后下载 pdf 的程序。网络是一个 aspx,使用 selenium,我可以在字段中正确输入信息:

input_user=driver.find_element(By.XPATH, '//*[@name="ctl00$SPWebPartManager1$g_93bc4c3a_0f69_4097_bed1_978c8b545335$freetext"]')
textolibre="jamaica"
input_user.send_keys(textolibre)

但返回结果的页面是相同的(aspx),我无法下载 pdf。

我希望能够在不使用 selenium 打开浏览器的情况下输入表单中的字段。我尝试使用 PhantomJS,但它说:

UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead

当你返回结果时,我可以下载它们,考虑到 url 不会改变。

【问题讨论】:

    标签: python selenium phantomjs


    【解决方案1】:

    在使用 PhantomJS 时,只需在您的代码中添加 2 行

    import warnings
    warnings.filterwarnings("ignore")
    

    否则,如果您将 gekodriver 用于 firefox 浏览器,则可以在代码中使用它

    opts = webdriver.FirefoxOptions()
    opts.headless = True
    driver = webdriver.Firefox(options=opts, executable_path='Your gekdriver exe path')
    

    如果你能分享更详细的完整代码,我可以更有效地帮助你

    【讨论】:

    • warnings.filterwarnings("ignore") 很有帮助。
    • 总是乐于提供帮助
    猜你喜欢
    • 2020-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 2020-11-23
    • 2019-05-26
    • 2019-05-19
    • 2019-01-31
    相关资源
    最近更新 更多