extract the information in a div class to a json object (or data frame)

前端 未结 2 1094
一整个雨季
一整个雨季 2021-01-24 03:54

For each row in the table on this page, I would like to click on the ID (e.g. the ID of row 1 is 270516746) and extract/download the information (which does NOT have the same he

2条回答
  •  臣服心动
    2021-01-24 04:40

    You dont have to click with the text visible. You can generate generic xpaths like :

    "(//table//td[1])//button[@data-target]"
    

    This will detect all buttons in the first column of the table. So you can go on loop.

    count= len(driver.find_elements_by_xpath("(//table//td[1])//button[@data-target]"))
    for i in range(count):
        driver.find_element_by_xpath("((//table//td[1])//button[@data-target])[" + str(i+1) + "]").click()
        # to get text content from pop up window 
        text = driver.find_element_by_xpath("//div[@class='modal-content']").text
        # then click close 
        driver.find_element_by_xpath("//button[text()='Close']").click()
    

提交回复
热议问题