Selenium Python - Access next pages of search results

前端 未结 2 1792
面向向阳花
面向向阳花 2021-01-21 14:15

I have to click on each search result one by one from this url:

Search Guidelines

I first extract the total number of results from the displayed text so that I c

2条回答
  •  轮回少年
    2021-01-21 14:37

    There is not even the need to programatically press on the Next button, if you see carrefully, the url just needs a new parameter when browsing other result pages:

    url = "http://www.nice.org.uk/Search.do?searchText=bevacizumab&newsearch=true&page={}#showfilter"
    
    for i in range(1,5):
        driver.get(url.format(i))
    
        upperlimit=driver.find_element_by_id("total_results")
        number = int(upperlimit.text.split(' ')[0])
    

    if you still want to programatically press on the next button you could use:

    driver.find_element_by_class_name('next').click()
    

    But I haven't tested that.

提交回复
热议问题