Files
qiming/qiming-mcp-proxy/mcp-proxy/fixtures/rfunction_python.py
2026-06-01 13:03:20 +08:00

27 lines
663 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import requests
from bs4 import BeautifulSoup
# 发送请求到百度
url = 'https://www.baidu.com'
response = requests.get(url)
# 检查请求是否成功
if response.status_code == 200:
# 解析网页内容
soup = BeautifulSoup(response.text, 'html.parser')
# 提取你想要的信息,例如标题
title = soup.title.string
else:
print(f"请求失败,状态码:")
# 入口函数不可修改否则无法执行args 为配置的入参
def main(args: dict) -> dict:
params = args.get("params")
# 构建输出对象出参中的key需与配置的出参保持一致
ret = {
"key": "value"
}
return ret