ruffyen

Untitled

Jun 21st, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. #!/usr/bin/python                                                                                                                                        
  2. import urllib2
  3.  
  4. def get_html(ASIN):
  5.     headers = {
  6.         'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/420+ (KHTML, like Gecko) Chrome/14.0.835.186 Safari/419.3'
  7.         }
  8.  
  9.     if ASIN != 'NoURL':
  10.         req = urllib2.Request(
  11.             url = 'http://www.amazon.com/gp/offer-listing/%s?condition=new' % (ASIN),
  12.             headers = headers
  13.             )
  14.         print ' [d] requesting req'
  15.         resp = urllib2.urlopen(req)
  16.         print ' [d] reading resp'
  17.         data = resp.read()
  18.  
  19.         print ' [d] returning data...'
  20.         return data
  21.     else:
  22.         return None
Advertisement
Add Comment
Please, Sign In to add comment