CertificateError: hostname 'www.wdylike.appspot.com' doesn't match

CertificateError: hostname 'www.wdylike.appspot.com' doesn't match

我正在学习关于学习的大胆课程 python。基本上,这个项目应该检查文件中的亵渎。我们使用网站“https://wdylike.appspot.com/?q=”来执行此操作。该网站检查是否存在脏话,如果存在或不存在脏话,则打印一个布尔值。不幸的是,他们在 python 2.7 中教授这门课程,而我有 python 3.5,并且有一些变化。所以,我转向你。每当我 运行 下面的代码时,我都会收到错误消息。我将在代码下方显示确切的错误。

import urllib.request as urlr

def read_text():
    quotes = open(r"C:\Users\setup\Documents\Sophomore Year\Math\Code_Help.txt")
    contents_of_file = quotes.read()
    print(contents_of_file)
    quotes.close()
    check_profanity(contents_of_file)

def check_profanity(text_to_check):
    print(text_to_check)
    link = ("https://www.wdylike.appspot.com/?q=")
    connection = urlr.urlopen (link + text_to_check)
    output = connection.read()
    print(output)
    connection.close()

read_text()

错误是:

CertificateError: hostname 'www.wdylike.appspot.com' doesn't match either of '*.appspot-preview.com', '*.appspot.com', '*.thinkwithgoogle.com', '*.withgoogle.com', '*.withyoutube.com', 'appspot-preview.com', 'appspot.com', 'thinkwithgoogle.com', 'withgoogle.com', 'withyoutube.com'

附加信息: 您在 (r"C:\Users\setup\Documents\Sophomore Year\Math\Code_Help.txt") 中看到的文件只是一个包含单词 "ass" 的文本文件,以便触发亵渎检测器。

感谢您的帮助。

您收到错误消息 CertificateError: hostname 'www.wdylike.appspot.com' doesn't match either of '*.appspot-preview.com', '*.appspot.com', '*.thinkwithgoogle.com', '*.withgoogle.com', '*.withyoutube.com', 'appspot-preview.com', 'appspot.com', 'thinkwithgoogle.com', 'withgoogle.com', 'withyoutube.com'

如果你仔细阅读,你会发现你的代码没有任何问题。它只是说 url (www.wdylike.appspot.com) 与证书有效的任何内容都不匹配。证书必须匹配 url。尝试使用不同的 urls。