20 lines
447 B
Python
20 lines
447 B
Python
import urllib.request
|
|
import ssl
|
|
|
|
API_URL = "https://dict.youdao.com/jsonapi?q=word"
|
|
|
|
|
|
def main():
|
|
# 创建不验证 SSL 的上下文
|
|
context = ssl._create_unverified_context()
|
|
|
|
try:
|
|
with urllib.request.urlopen(API_URL, context=context) as response:
|
|
body = response.read().decode('utf-8')
|
|
print(body)
|
|
except Exception as e:
|
|
print(f"请求出错: {e}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |