diff --git a/const.py b/const.py index 889d202..ff0a8c1 100644 --- a/const.py +++ b/const.py @@ -22,7 +22,7 @@ SECRET_KEY = 'iPXte32y1deoySiDq0RwONUJIiIgvjTVhbfCL8tV' BUCKET = 'facebook' # PROXY -PROXY_HOST = 'http://api.proxy.ip2world.com/getProxyIp?num=1®ions=us&lb=1&return_type=json&protocol=sock5' +PROXY_HOST = 'http://123.58.209.87:5010/get/?type=https' api_key = "adf0d1fc9c9313b7f87c18bf9caef01d" diff --git a/spider/task.py b/spider/task.py index 2766efd..a9553db 100644 --- a/spider/task.py +++ b/spider/task.py @@ -769,15 +769,12 @@ def get_proxy_from_api(): if response.status_code == 200: proxy_data = response.json() # 根据你的API返回格式调整 - proxy_datum = proxy_data['data'][0] - proxy_ip = proxy_datum['ip'] - proxy_port = proxy_datum['port'] + p = proxy_data.get("proxy") + if p: + return f"http://{p}" - if proxy_ip and proxy_port: - return f"socks5://{proxy_ip}:{proxy_port}" - - raise OperationFailed("获取代理时出错") + raise OperationFailed(f"获取代理时出错={proxy_data}") except Exception as e: raise OperationFailed("获取代理时出错") from e @@ -1000,8 +997,12 @@ if __name__ == '__main__': # cookies = playwright_login('61576195641387', 'osman@@5', 'Z7U32HAU3RDVE6JE5WEXATOOH6DLPUHV') # print(cookies) # pass - cookies = playwright_m_login('61576995257902', 'djkufhhh', 'R56AR2LXBK664C6N4AQX2CPV2SL6FOFW') - print(cookies) + + # 测试获取代理 + print(get_proxy_from_api()) + + # cookies = playwright_m_login('61576995257902', 'djkufhhh', 'R56AR2LXBK664C6N4AQX2CPV2SL6FOFW') + # print(cookies) # 点赞 # cookies_list = [