Container commited on
Commit
e37298f
·
verified ·
1 Parent(s): 1d8d56e

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +25 -0
main.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from selenium import webdriver
2
+ from selenium.webdriver.chrome.options import Options
3
+
4
+ # 设置无头浏览器选项
5
+ options = Options()
6
+ options.headless = True
7
+
8
+ # 初始化WebDriver
9
+ driver = webdriver.Chrome(options=options)
10
+
11
+ # 访问网址
12
+ driver.get("https://example.com/")
13
+
14
+ # 网页加载后,Selenium会处理JavaScript代码,包括设置cookie和跳转
15
+
16
+ # 您可以检查cookie
17
+ cookies = driver.get_cookies()
18
+ print(cookies)
19
+
20
+ # 您也可以获取当前URL,检查是否发生了跳转
21
+ current_url = driver.current_url
22
+ print(current_url)
23
+
24
+ # 关闭浏览器
25
+ driver.quit()