'How to Get the Webpage Title of Chrome?

Using python, is there a way to obtain the title of the current active tab in Chrome?

If it is impossible, getting the list of titles of all tabs also works for my purpose. Thanks.



Solution 1:[1]

There's multiple way of getting the title of a the current tab using Python,

You could use BeatifulSoup

import urllib2
from BeautifulSoup import BeautifulSoup

soup = BeautifulSoup(urllib2.urlopen("https://www.google.com"))
print soup.title.string

Or if your using Selenium

from selenium import webdriver

driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")

driver.maximize_window()

driver.get(YOUR_URL)

print(driver.title)
print(driver.current_url)
driver.refresh()
driver.close()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rl242Dev