MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / _fetch_script

Method _fetch_script

app/services/tdc_service.py:146–176  ·  view source on GitHub ↗
(
        self,
        url: str,
        *,
        account: AccountRecord,
        user_agent: str,
    )

Source from the content-addressed store, hash-verified

144 "GET",
145 url,
146 headers={
147 "Accept": "application/javascript, text/javascript, */*; q=0.01",
148 "Referer": self.settings.tencent_captcha_entry_url,
149 },
150 proxy_url=account.proxy_url or None,
151 user_agent=user_agent or None,
152 browser_impersonate=account.browser_impersonate or None,
153 )
154 cache_path.parent.mkdir(parents=True, exist_ok=True)
155 cache_path.write_text(code, encoding="utf-8")
156 return code
157
158 def _run_vm(
159 self,
160 *,
161 tdc_code: str,
162 ft_code: str,
163 account: AccountRecord,
164 user_agent: str,
165 ) -> dict[str, Any]:
166 if not self.runner_path.exists():
167 raise BadRequestError("TDC VM runner 不存在,项目文件可能没打全")
168
169 self.cache_dir.mkdir(parents=True, exist_ok=True)
170 temp_dir = tempfile.mkdtemp(dir=self.cache_dir)
171 try:
172 temp_path = Path(temp_dir)
173 tdc_path = temp_path / "tdc.js"
174 ft_path = temp_path / "ft.js"
175 input_path = temp_path / "input.json"
176 tdc_path.write_text(tdc_code, encoding="utf-8")
177 ft_path.write_text(ft_code, encoding="utf-8")
178 input_path.write_text(
179 json.dumps(

Callers 1

collect_for_challengeMethod · 0.95

Calls 3

_cache_pathMethod · 0.95
BadRequestErrorClass · 0.90
request_textMethod · 0.80

Tested by

no test coverage detected