-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathselenium_first.py
More file actions
31 lines (24 loc) · 895 Bytes
/
selenium_first.py
File metadata and controls
31 lines (24 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
# http://httpbin.org/get
with open('ip.txt') as f:
lines = (line.strip() for line in f)
ip = list(lines)
with open('user_agent.txt') as f:
lines = (line.strip() for line in f)
user_agent = list(lines)
# 添加配置
options = webdriver.ChromeOptions()
options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36")
options.add_argument("proxy-server=http://117.191.11.105:8080")
# 创建浏览器驱动
driver = webdriver.Chrome(options=options)
driver.get("http://httpbin.org/get")
# input = driver.find_element(By.CSS_SELECTOR, '#kw')
# input.send_keys("如吉生物")
# button = driver.find_element(By.CSS_SELECTOR, '#su')
# button.click()
print(driver.page_source)
time.sleep(10)
driver.quit()