Monday, May 6, 2019

Example file for retrieving data from the internet - Python 3

# Example file for retrieving data from the internet
#
import urllib.request # instead of urllib2 like in Python 2.7

def main():
# open a connection to a URL using urllib2
webUrl = urllib.request.urlopen("http://www.google.com")
# get the result code and print it
print ("result code: " + str(webUrl.getcode()))
# read the data from the URL and print it
data = webUrl.read()
print (data)

if __name__ == "__main__":
main()

No comments:

Post a Comment

Faith & Evolution: An Evangelical Guide for Youth Groups

  Summary: Many Evangelical Christians affirm that faith in Jesus and acceptance of science (including evolution) can go hand-in-hand . Bo...