Sunday, September 25

Class 3 - Python!!!! HACKING!!

During this class we focused on python and we learned some basics on how to use it, in class i dont know if i am the only that feels liek this but i just dont think we went through the program very well i just did not understand how to use it well, i had troble with the coding part and had to ask for help to my other peers and at the end I was able to to get my lab working but if it wasnt for my peers i would have never been able to complete it. i would like to go over this topic again but in more detail.

I find this program to be amazing just because of the things that can be accomplish by coding out a script and running it, you will be able to obtain a lot of information and not just information probably even control something or run something in the background.

for our lab this week, we had to open a connection with a public web server and then be able to obtain GET request from the page using HTTP and a HEAD request , also the program should include and return the value and display the server banner, the date of the day, and the status.
This is how i came up with the code, ofcourse with the help of my peers just like i mention before i would have never been able to complete it without their help

import httplib #import library
connection = httplib.HTTPConnection('www.google.ca')  # set connection to desired URL
connection.request('HEAD', '/index.html') #  Use GET to query the web site index
getResp = connection.getresponse()  # Gathers large string from GET command
server = getResp.getheader('server')  # use getresponse to getheader("specific instance")
date = getResp.getheader('date')
status = getResp.status
print 'Server Name is: ' + server
print 'Date : ' + date
print 'Status : ' + str(status) + " " + getResp.reason # converts status to string and concats it to status =
connection.close()


That is the code put in python that did the job :)

1 comment:

  1. Hey the class sounds interesting, would like to learn some of that just as a hobby

    ReplyDelete