|
- from selenium import webdriver
- driver = webdriver.Edge()
- driver.get('https://www.baidu.com/')
- url = driver.current_url
- driver.back()
- driver.forward()
- driver.refresh()
- driver.title
- driver.set_window_size(1920, 1080)
- driver.maximize_window()
- driver.minimize_window()
- driver.fullscreen_window()
- driver.find_element(By.ID, 'kw').send_keys('selenium') #搜索框输入selenium
- driver.find_element(By.ID, 'su').click() # 点击百度一下
- driver.quit()
- <pre><code class="language-python"><pre class="dqa-code-pre"><code class="dqa-code-block hljs"><div class="hljs-ln-line hljs-ln-code"><span class="hljs-comment"># 通过tag name定位span</span></div><div class="hljs-ln-line hljs-ln-code">span_by_tag = driver.find_element(By.TAG_NAME, <span class="hljs-string">'span'</span>)</div><div class="hljs-ln-line hljs-ln-code"><span class="hljs-built_in">print</span>(span_by_tag.text)</div></code></pre></code></pre>
复制代码
|
|