WebHacking: README, urllib2 scripts

This commit is contained in:
Mari Wahl 2014-12-29 13:06:07 -05:00
parent 54d8d02892
commit a36bde60b7
15 changed files with 209 additions and 99 deletions

View file

@ -0,0 +1,25 @@
#!/usr/bin/env python
__author__ = "bt3"
import urllib2
def get(url):
msg = urllib2.urlopen(url)
print msg.read()
def get_user_agent(url):
headers = {}
headers['User-Agent'] = 'Googlebot'
request = urllib2.Request(url, headers=headers)
response = urllib2.urlopen(request)
print response.read()
response.close()
if __name__ == '__main__':
HOST = 'http://www.google.com'
get_user_agent(HOST)