0

I got to the point of grabbing a list of elements by xpath but having trouble grabbing the html behind it.

with this I grab the followers found by the xpath and print them out as how many I received, but I need to get the html of that xpath so that I can recive the text included in them

 old_followers = 0
        followers = driver.find_elements_by_xpath('//*[@role="dialog"]//ul/div/li')
        dialog = driver.find_element_by_xpath('//div[@class="isgrP"]')
        while old_followers != followers:
            old_followers = followers

            driver.execute_script("arguments[0].scrollBy(0,600)", dialog)
            time.sleep(2)
            driver.execute_script("arguments[0].scrollBy(0,600)", dialog)
            time.sleep(2)

            followers = driver.find_elements_by_xpath('//*[@role="dialog"]//ul/div/li')
            print(len(followers))
James Shaw
  • 113
  • 1
  • 5

1 Answers1

0

Assuming you are using the Selenium Webdriver, when getting the element:

element.get_attribute('innerHTML')

Possibly a similar question: Get HTML Source of WebElement in Selenium WebDriver using Python