Advertisement
gauravssnl

urllib2_introduction

Sep 29th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. #introduction to urllib2
  2. import urllib2
  3. import httplib
  4.  
  5.  
  6. #set httplib debuglevel
  7. httplib.HTTPConnection.debuglevel=1
  8. url= "http://cmyip.com/"
  9.  
  10. #Request
  11. request=urllib2.Request(url)
  12. #build opener
  13. opener=urllib2.build_opener()
  14. data=opener.open(request).read()
  15.  
  16. print repr(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement