Python | page_source method in Selenium Read Courses Practice Improve Improve Improve Like Article Like Save Article Save Report issue Report page_source method is used retrieve the page source of the webpage the user is currently accessing. The main use of this method to find something in the page source like finding any data or keyword. Page source : The source code/page source is the programming behind any webpage. Syntax : driver.page_source Argument : It takes no argument. Return value : It return the page source in string format. Code 1. # importing webdriver from selenium from selenium import webdriver # Here Chrome will be used driver = webdriver.Chrome() # URL of the website url = "https://www.geeksforgeeks.org/" # Opening the URL driver.get(url) # Getting current URL source code get_source = driver.page_source # Printing the URL print(get_source) Output : This code will print the source code of the “https://www.geeksforgeeks.org/”. Code 2. When no web page is opened. # importing webdriver from selenium from selenium import webdriver # Here Chrome will be used driver = webdriver.Chrome() # Getting current URL source code get_source = driver.page_source # Printing the URL print(get_source) Output : Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills, become a part of the hottest trend in the 21st century.Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve. Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore. Last Updated : 06 Mar, 2020 Like Article Save Article Previous Pytube | Python library to download youtube videos Next Python - First Even Number in List Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads page_source driver method - Selenium Python How to use close() and quit() method in Selenium Python ? Python - find_element() method in Selenium Navigating links using get method - Selenium Python find_element(By.Name) driver method - Selenium Python find_element(By.XPATH) driver method - Selenium Python find_element_by_class_name() driver method - Selenium Python find_element() driver method - Selenium Python find_element_by_css_selector() driver method - Selenium Python find_elements_by_name() driver method - Selenium Python Complete Tutorials SVG Tutorial HTML Canvas Tutorial Python API Tutorial: Getting Started with APIs Advanced Python Tutorials Python Automation Tutorial Like R rakshitarora Follow Article Tags : Python-selenium Python Web Technologies Practice Tags : python Additional Information Vote for difficulty : Easy Normal Medium Hard Expert