Python loop and append data to a master

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alkaline5
    New Member
    • Mar 2020
    • 2

    Python loop and append data to a master

    Hi everyone, I've created a web scraper that scrapes the information I need from a table on a website. It clicks through 6 pages, but it ends up only including the last page at the end of my loop rather than appending as it goes. I'm new to for loops and Python and hoping for some guidance. Here is my code:

    Code:
    while True:
        driver.implicitly_wait(30)
        table = driver.find_element_by_id('preblockBody')
        information = []
        job_elems = table.find_elements_by_xpath("//*[contains(@class,'pbListingTable')]")
        for value in job_elems:
            information.append(value.text)
         
        try:
            driver.find_element_by_partial_link_text('Next').click()
        except:
            break
    
    driver.quit()
    print(information)
    Where should I put the append so it properly runs?
  • alkaline5
    New Member
    • Mar 2020
    • 2

    #2
    I was able to figure this out, but not sure how to mark as solved. Had a moment of clarity after posting!

    Comment

    Working...