【问题标题】:Click on the button on website点击网站上的按钮
【发布时间】:2014-05-06 14:05:01
【问题描述】:

您是否失去了对网站的浏览,我需要使用 python 点击​​页面底部的“Další holky prosím”http://www.lide.cz/ 我试图编写一些程序,但它不起作用。请咨询谢谢

with closing(Firefox()) as browser:
 browser.get('http://www.lide.cz/')

 options=browser.find_elements_by_class_name("span.button.zeny")
 for i in options:
     print('nasel')
     i.click()

 page_source = browser.page_source
 soup = BeautifulSoup(page_source)
 for i in soup.findAll('a'):``
     out=(i).get("href")
     if out.find('/detail/')!= -1:
        print(out)

【问题讨论】:

    标签: python firefox selenium


    【解决方案1】:

    尝试替换

    options=browser.find_elements_by_class_name("span.button.zeny")
    

    options=browser.find_elements_by_xpath('//*[@id="profiles"]')
    

    【讨论】:

      【解决方案2】:

      要点击“Další holky prosím”按钮,你可以试试这个:

      options=browser.find_elements_by_class_name(".button") // css selector
      

      或者这个:

      options=browser.find_elements_by_xpath('//span[@class="button zeny"]') //xpath expression
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-10-17
        • 1970-01-01
        • 2016-11-26
        • 1970-01-01
        • 2016-03-30
        • 2019-11-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多