less than 1 minute read
As I mentioned in one of my previous post, I started with learning Python.
Here is one of the first scripts I wrote. It grabs the HTTP Response header. Great thing is that it’s possible to do this with only 7 lines of code.
#!/usr/bin/python import urllib2 import sys url = raw_input("Full url:") url.rstrip() header = urllib2.urlopen(url).info() print(str(header))
$>Full url: http://www.jovicailic.org
As a result, you should get something like:
Date: Wed, 13 Mar 2013 12:35:43 GMT Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimi ted/1.4 X-Powered-By: PHP/5.2.9 Vary: Accept-Encoding,Cookie Cache-Control: max-age=3, must-revalidate WP-Super-Cache: Served supercache file from PHP Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8
If you liked the post, we should get connected - follow me on Twitter