证书错误:主机名'www.wdylike.appspot.com'不匹配



我正在学习学习python的Udacity课程。基本上,该项目应该检查文件中的亵渎性。我们使用网站" https://wdylike.appspot.com/?q="来执行此操作。该网站会检查亵渎性,并在没有亵渎的情况下打印布尔值。不幸的是,他们在Python 2.7中教了课程,而我有Python 3.5,并且有一些变化。所以,我转向你。每当我在下面运行代码时,都会出现错误。我将在代码下方显示确切的错误。

import urllib.request as urlr
def read_text():
    quotes = open(r"C:UserssetupDocumentsSophomore YearMathCode_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 sedup sifor sear math 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匹配。尝试使用不同的URL。

最新更新