fix
This commit is contained in:
parent
638e98b0e9
commit
1627d3cf89
18
server.py
18
server.py
@ -42,11 +42,25 @@ print("跳转小红书首页成功,等待调用")
|
|||||||
|
|
||||||
|
|
||||||
def sign(uri, data, a1, web_session):
|
def sign(uri, data, a1, web_session):
|
||||||
|
try:
|
||||||
|
# Ensure the page is still valid and reload if necessary
|
||||||
|
if context_page.is_closed():
|
||||||
|
global browser_context, context_page
|
||||||
|
browser_context, context_page = get_context_page(playwright, stealth_js_path)
|
||||||
|
context_page.goto("https://www.xiaohongshu.com")
|
||||||
|
time.sleep(5)
|
||||||
|
context_page.reload()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Evaluate the JavaScript function
|
||||||
encrypt_params = context_page.evaluate("([url, data]) => window._webmsxyw(url, data)", [uri, data])
|
encrypt_params = context_page.evaluate("([url, data]) => window._webmsxyw(url, data)", [uri, data])
|
||||||
return {
|
return {
|
||||||
"x-s": encrypt_params["X-s"],
|
"x-s": encrypt_params["X-s"],
|
||||||
"x-t": str(encrypt_params["X-t"])
|
"x-t": str(encrypt_params["X-t"])
|
||||||
}
|
}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error during sign operation: {e}")
|
||||||
|
return {"error": str(e)}
|
||||||
|
|
||||||
|
|
||||||
@app.route("/sign", methods=["POST"])
|
@app.route("/sign", methods=["POST"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user