Dify 整合
Dify 整合
Section titled “Dify 整合”為你的 Dify 工作流程加入受代理保護的網路存取。
HTTP Request 節點
Section titled “HTTP Request 節點”在 Dify 的 HTTP Request 節點中,設定 proxy:
- 在你的工作流程中加入一個 HTTP Request 節點
- 將 URL 設為你的目標
- 在 Advanced Settings 中加入 proxy 設定:
Proxy URL: http://session_id:[email protected]:8080Code 節點
Section titled “Code 節點”若需要更多控制,使用 Code 節點:
import requestsimport hashlibimport time
API_KEY = "sk-your-key"TARGET = "amazon.com"
# 從 HydraSkill API 取得 proxyproxy_resp = requests.get( "https://api.hydraskill.ai/v1/proxy", params={"target": TARGET, "session_lock": "true"}, headers={"Authorization": f"Bearer {API_KEY}"}).json()
# 使用該 proxyproxy_url = f"http://{proxy_resp['username']}:{proxy_resp['password']}@{proxy_resp['host']}:{proxy_resp['port']}"result = requests.get( f"https://{TARGET}/product-page", proxies={"http": proxy_url, "https": proxy_url})
return {"content": result.text, "status": result.status_code}在 Dify 中的好處
Section titled “在 Dify 中的好處”- 存取外部 URL 的工作流程節點不會因 IP 封鎖而失敗
- 跨多步驟工作流程維持一致的 session
- 不需要在工作流程邏輯中處理 proxy 錯誤