from datetime import datetime import requests def save_to_showdoc(cat_name, page_title, markdown_string): # 接口的URL url = "http://192.168.0.29:29011/server/index.php?s=/api/item/updateByApi" # 请求头中添加api_key(这里假设按照你说的只是把这个链接作为api_key的值,实际可能需要根据真实情况调整) headers = { "Hm_lvt_4d9f9fa20dc17ceda35728278660ac7b": "1765869152623|1734332165" } try: begin_date = datetime.now().strftime('%Y-%m-%d') print(f"当天日期: {begin_date}") # 构造POST请求的数据(示例数据,可替换为实际要发送的数据) data = { "api_key": "7d711192bea02ccd4f4733cc0e9f394c138081675", "api_token": "f1e6f7f71bf25f0879fedef722bd90ea583708218", "cat_name": cat_name, "page_title": f"{page_title}-{begin_date}", "page_content": markdown_string, "s_number": 1 } try: # 发送POST请求 response = requests.post(url, headers=headers, data=data) # 检查响应状态码,如果是200表示请求成功,可根据实际情况调整判断逻辑 if response.status_code == 200: print("请求成功,响应内容如下:" + markdown_string) else: print(f"请求失败,状态码:{response.status_code}") except requests.RequestException as e: print(f"请求出现异常:{e}") except requests.RequestException as e: print(f"请求出现异常:{e}") if __name__ == "__main__": save_to_showdoc('大模型/ai', 'deepseek', '1')