Get html from element with Python selenium

Task

I am using selenium and want to get the source HTML for the elements obtained by find_element_by_〇〇 such as find_element_by_class_name.

I try to get the source with .page_source, but

AttributeError: 'WebElement' object has no attribute 'page_source'

An error like this occurs.

Solution

You can get HTML by the following method.

element.get_attribute('innerHTML')

Reference: https://stackoverflow.com/questions/7263824/get-html-source-of-webelement-in-selenium-webdriver-using-python

Recommended Posts

Get html from element with Python selenium
[Note] Get data from PostgreSQL with Python
ScreenShot with Selenium (Python)
Get date with python
Scraping with Selenium [Python]
Get country code with python
Scraping with selenium in Python
Scraping with Selenium + Python Part 1
Get Twitter timeline with python
Get Youtube data with python
Python: Working with Firefox with selenium
Get schedule from Garoon SOAP API with Python + Zeep
Scraping with Selenium in Python
Get thread ID with python
Get mail from Gmail and label it with Python3
Scraping with Selenium + Python Part 2
Get started with Python! ~ ② Grammar ~
Get stock price with Python
Get home directory with python
Get keyboard events with python
With skype, notify with skype from python!
Get data from database via ODBC with Python (Access)
Run iphone safari from mac with python + selenium + safari-webdriver
Get Alembic information with Python
Get a list of purchased DMM eBooks with Python + Selenium
Get data from analytics API with Google API Client for python
Get message from first offset with kafka consumer in python
Python: Exclude tags from html data
Get started with Python! ~ ① Environment construction ~
Call C from Python with DragonFFI
Link to get started with python
Using Rstan from Python with PypeR
Get data from Quandl in Python
Get reviews with python googlemap api
Scraping with Selenium in Python (Basic)
Install Python from source with Ansible
Create folders from '01' to '12' with python
Scraping with Python, Selenium and Chromedriver
Get the weather with Python requests
Get web screen capture with python
Get the weather with Python requests 2
Get one column from DataFrame with DataFrame
[Python] Get economic data with DataReader
How to get started with Python
Run Aprili from Python with Orange
[Small story] Get timestamp with Python
Get Qiita trends with Python scraping
Get upcoming weather from python weather api
Call python from nim with Nimpy
Read fbx from python with cinema4d
Get started with Python in Blender
Get weather information with Python & scraping
Get PowerShell commands from malware dynamic analysis site with BeautifulSoup + Python
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
[Python] Get the update date of a news article from HTML
Get US stock price from Python with Web API with Raspberry Pi
Operate Firefox with Selenium from python and save the screen capture
Collecting information from Twitter with Python (Twitter API)
Get property information by scraping with python
Receive textual data from mysql with python
Get exchange rates from open exchange rates in Python