Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,22 +12,37 @@ app = FastAPI()
|
|
| 12 |
|
| 13 |
@app.get("/")
|
| 14 |
def main():
|
|
|
|
|
|
|
|
|
|
| 15 |
options = Options()
|
| 16 |
options.add_argument('--headless')
|
| 17 |
driver = webdriver.Chrome(options=options)
|
| 18 |
-
driver.get(
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
cookies = driver.get_cookies()
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
driver.quit()
|
| 30 |
-
return {"code": 200,"
|
| 31 |
|
| 32 |
if __name__ == '__main__':
|
| 33 |
uvicorn.run(app='app:app', host="0.0.0.0", port=7860)
|
|
|
|
| 12 |
|
| 13 |
@app.get("/")
|
| 14 |
def main():
|
| 15 |
+
target_url = 'https://test5.container-z.art/test26'
|
| 16 |
+
wait_time = 10
|
| 17 |
+
|
| 18 |
options = Options()
|
| 19 |
options.add_argument('--headless')
|
| 20 |
driver = webdriver.Chrome(options=options)
|
| 21 |
+
driver.get(target_url)
|
| 22 |
+
|
| 23 |
+
time.sleep(wait_time)
|
| 24 |
|
| 25 |
+
# 获取当前URL
|
| 26 |
+
current_url = driver.current_url
|
| 27 |
|
| 28 |
+
# 获取页面源代码
|
| 29 |
+
page_source = driver.page_source
|
| 30 |
+
|
| 31 |
+
# 获取cookie
|
| 32 |
cookies = driver.get_cookies()
|
| 33 |
+
|
| 34 |
+
# 是否有跳转过
|
| 35 |
+
is_jump = (target_url != current_url)
|
| 36 |
|
| 37 |
+
data = {
|
| 38 |
+
"url": current_url,
|
| 39 |
+
"page_source": page_source,
|
| 40 |
+
"cookies": cookies,
|
| 41 |
+
"is_jump": is_jump
|
| 42 |
+
}
|
| 43 |
|
| 44 |
driver.quit()
|
| 45 |
+
return {"code": 200,"data":data}
|
| 46 |
|
| 47 |
if __name__ == '__main__':
|
| 48 |
uvicorn.run(app='app:app', host="0.0.0.0", port=7860)
|