from selenium import webdriver import time browser = webdriver.Chrome() browser.get(‘https://www.baidu.com‘) #打印网页标题 print(browser.title) #输出内容:百度一下,你就知道
from selenium import webdriver import time browser = webdriver.Chrome() browser.get(‘https://www.baidu.com‘) #打印网页标题 print(browser.current_url) #输出内容:https://www.baidu.com/
from selenium import webdriver import time browser = webdriver.Chrome() browser.get(‘https://www.baidu.com‘) #打印网页标题 print(browser.capabilities[‘version‘]) #输出内容:67.0.3396.87
from selenium import webdriver import time browser = webdriver.Chrome() browser.get(‘https://www.baidu.com‘) #定位输入框 input_box = browser.find_element_by_id(‘kw‘) #打印输入框尺寸 print(input_box.size) #输出内容:{‘height‘: 22, ‘width‘: 500}
from selenium import webdriver import time browser = webdriver.Chrome() browser.get(‘https://www.baidu.com‘) #定位备案元素 recordcode = browser.find_element_by_id(‘jgwab‘) #打印备案元素信息 print(recordcode.text) #输出内容:京公网安备11000002000001号
# coding=utf-8 import time from selenium import webdriver driver = webdriver.Chrome() driver.maximize_window() driver.implicitly_wait(6) driver.get("https://www.baidu.com") time.sleep(1) for link in driver.find_elements_by_xpath("//*[@href]"): print (link.get_attribute(‘href‘)) driver.quit()
本文章转自:https://www.cnblogs.com/xiao-xue-di/p/11531894.html
原文:https://www.cnblogs.com/FBGG/p/15251729.html