MCPcopy Create free account
hub / github.com/Alibaba-NLP/DeepResearch / readpage

Method readpage

WebAgent/WebWeaver/tool/tool_retrieve.py:47–63  ·  view source on GitHub ↗
(self, url: str)

Source from the content-addressed store, hash-verified

45 self.scraper_country_code = "us"
46 self.scraper_time_out = 40
47 def readpage(self, url: str) -> str:
48 payload = {'api_key': self.scraper_key,
49 'url': url,
50 'output_format': 'markdown',
51 'country_code': self.scraper_country_code }
52 max_retries = 2
53 for attempt in range(max_retries):
54 try:
55 r = requests.get('https://api.scraperapi.com/', params=payload, timeout=self.scraper_time_out)
56 content = r.text
57 return content
58 except requests.exceptions.Timeout:
59 # 超时情况下返回默认内容
60 content = "[visit] Request timed out after {} seconds. Using default content.".format(self.scraper_time_out)
61 except Exception as e:
62 content ="[visit] Failed to read page."
63 return content
64
65
66@register_tool('retrieve', allow_overwrite=True)

Callers 1

scraper_readpageMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected