点击网站上的按钮

时间:2014-05-06 14:05:02

标签: python firefox selenium

你是否失去了对网站的浏览,我需要使用python点击页面底部的“Dalšíholkyprosí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)

2 个答案:

答案 0 :(得分:0)

尝试替换

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

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

答案 1 :(得分:0)

要点击“Dalšíholkyprosím”按钮,您可以试试这个:

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

或者这个:

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