python中 代码访问某个网站

import urllib

 

 

def read_text():

    quotes = open("/Users/Scarlett/Downloads/movie_quotes/movie_quotes.txt")

    contents_of_file = quotes.read()

    quotes.close()

    check_profanity(contents_of_file)

 

def check_profanity(text_to_check):

    url = "http://www.wdylike.appspot.com/?q=" + text_to_check

    # print(url)

    connection = urllib.urlopen("http://www.wdylike.appspot.com/?q=" + "shit")

    output = connection.read()

    print(output)

    connection.close()

 

read_text()