Skip to content

Commit eb1d125

Browse files
committed
hacky try number 4
1 parent 4b3fa58 commit eb1d125

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crytic_compile/platform/etherscan.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,13 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
258258

259259
if not only_bytecode:
260260
if "polygon" in etherscan_url:
261-
etherscan_url = urllib.request.Request(etherscan_url,headers={"User-Agent": "Mozilla/5.0"})
262-
with urllib.request.urlopen(etherscan_url) as response:
263-
html = response.read()
261+
# build object with headers, then send request
262+
new_etherscan_url = urllib.request.Request(etherscan_url,headers={"User-Agent": "Mozilla/5.0"})
263+
with urllib.request.urlopen(new_etherscan_url) as response:
264+
html = response.read()
265+
else:
266+
with urllib.request.urlopen(etherscan_url) as response:
267+
html = response.read()
264268

265269
info = json.loads(html)
266270

0 commit comments

Comments
 (0)