参考文章:http://www.cnblogs.com/paisen/p/3289708.html
from selenium import webdriver
import time
browser = webdriver.Chrome()
first_url = 'http://www.baidu.com'
browser.get(first_url)
browser.find_element_by_xpath('//*[@id="kw"]').send_keys('hello world')
time.sleep(3)
browser.find_element_by_xpath('//*[@id="1"]/h3/a/em').click()
browser.switch_to.window(browser.window_handles[0])
print(browser.title) # 第一个页面
browser.switch_to.window(browser.window_handles[1])
print(browser.title) # 最后一个页面
time.sleep(1)
browser.switch_to.window(browser.window_handles[0])
# browser.quit()