MCPcopy Create free account
hub / github.com/RUC-NLPIR/WebThinker / parse_urls

Method parse_urls

demo/bing_search.py:65–84  ·  view source on GitHub ↗

发送URL列表到解析服务器并获取解析结果 Args: urls: 需要解析的URL列表 timeout: 请求超时时间,默认20秒 Returns: 解析结果列表 Raises: requests.exceptions.RequestException: 当API请求失败时 requests.exceptions.Timeout: 当请求超时

(self, urls: List[str], timeout: int = 120)

Source from the content-addressed store, hash-verified

63 self.base_url = base_url.rstrip('/')
64
65 def parse_urls(self, urls: List[str], timeout: int = 120) -> List[Dict[str, Union[str, bool]]]:
66 """
67 发送URL列表到解析服务器并获取解析结果
68
69 Args:
70 urls: 需要解析的URL列表
71 timeout: 请求超时时间,默认20秒
72
73 Returns:
74 解析结果列表
75
76 Raises:
77 requests.exceptions.RequestException: 当API请求失败时
78 requests.exceptions.Timeout: 当请求超时时
79 """
80 endpoint = urljoin(self.base_url, "/parse_urls")
81 response = requests.post(endpoint, json={"urls": urls}, timeout=timeout)
82 response.raise_for_status() # 如果响应状态码不是200,抛出异常
83
84 return response.json()["results"]
85
86
87def remove_punctuation(text: str) -> str:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected