In [10]:
optxt = open('brief.txt', 'r')

In [11]:
filtxt = optxt.read()

In [12]:
filtxt


Out[12]:
'ok\nwe go to website - basically - sorry@\n\n\n\nlocalhost/redirect.py? everythingelse.html\nreferal header that was in the request\nif referal header:\nprint html \nthen javascript function to refresh and go to original url.\nif no referal header:\ngenerate htm header 302 redirect to that url. \n \n\n'

In [12]:
filtxt.

In [14]:
mksit = open('index.html', 'w')

In [14]:


In [15]:
import requests

In [17]:
opartz = requests.get('http://google.com')

In [20]:
headon = opartz.headers

In [21]:
headon


Out[21]:
CaseInsensitiveDict({'alternate-protocol': '80:quic', 'x-xss-protection': '1; mode=block', 'transfer-encoding': 'chunked', 'set-cookie': 'PREF=ID=95e682158b760972:FF=0:TM=1402819913:LM=1402819913:S=7k3yz6-efuOGL9l6; expires=Tue, 14-Jun-2016 08:11:53 GMT; path=/; domain=.google.com, NID=67=d6qZ3itIj0NvXmBhVFJ3cZSakHmgdoSKdIgwjmiBhs0-3CpXdlcMaYOC8yp9iHw1gmGp9Rbx5aCjRBBcLsRS7cdCO7XsN5DXm_KUGws-MFJh470BQBLIpFoX6ZjfrkY_; expires=Mon, 15-Dec-2014 08:11:53 GMT; path=/; domain=.google.com; HttpOnly', 'expires': '-1', 'server': 'gws', 'cache-control': 'private, max-age=0', 'date': 'Sun, 15 Jun 2014 08:11:53 GMT', 'p3p': 'CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."', 'content-type': 'text/html; charset=ISO-8859-1', 'x-frame-options': 'SAMEORIGIN'})

In [22]:
headon.keys()


Out[22]:
['alternate-protocol',
 'x-xss-protection',
 'transfer-encoding',
 'set-cookie',
 'expires',
 'server',
 'cache-control',
 'date',
 'p3p',
 'content-type',
 'x-frame-options']

In [23]:
print headon['server']


gws

In [24]:
checkser = headon['server']

In [27]:
if None in checkser:
    print checkser


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-27-352936c6c896> in <module>()
----> 1 if None in checkser:
      2     print checkser

TypeError: 'in <string>' requires string as left operand, not NoneType

In [28]:
if infoz in checkser:
    print onfoz


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-28-5702e367df49> in <module>()
----> 1 if infoz in checkser:
      2     print onfoz

NameError: name 'infoz' is not defined

In [31]:
for detas in checkser():
    print detas


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-31-4dbfb8bd0213> in <module>()
----> 1 for detas in checkser():
      2     print detas

TypeError: 'str' object is not callable

In [32]:
checkser


Out[32]:
'gws'

In [33]:
empstr = None

In [34]:
print empstr


None

In [36]:
is checkser = empstr


  File "<ipython-input-36-d820f78dad24>", line 1
    is checkser = empstr
     ^
SyntaxError: invalid syntax

In [39]:
is 4 == 5


  File "<ipython-input-39-2ea9824d7594>", line 1
    is (4 == 5)
     ^
SyntaxError: invalid syntax

In [40]:
is empstr in checkser


  File "<ipython-input-40-0a706d253e9b>", line 1
    is empstr in checkser
     ^
SyntaxError: invalid syntax

In [41]:
empstr in checkser


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-41-5de2d852a48f> in <module>()
----> 1 empstr in checkser

TypeError: 'in <string>' requires string as left operand, not NoneType

In [43]:
empstr

In [42]:
if empstr is None:
    print ('it is none')


it is none

In [ ]: