(
self,
url: str,
*,
account: AccountRecord,
user_agent: str,
)
| 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( |
no test coverage detected