Subversion Repositories SmartDukaan

Rev

Rev 14333 | Rev 14538 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14333 Rev 14366
Line 17... Line 17...
17
    def __init__(self):
17
    def __init__(self):
18
        self.count_trials = 0
18
        self.count_trials = 0
19
        self.redirectCount = 0
19
        self.redirectCount = 0
20
    
20
    
21
    def read(self, url):
21
    def read(self, url):
22
        request = urllib2.Request(url)
-
 
23
        request.add_header('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
-
 
24
        request.add_header('Accept-Language','en-US,en;q=0.8,hi;q=0.6')
-
 
25
        request.add_header('Connection','keep-alive')
-
 
26
        request.add_header('Cookie','T=TI141257426738726661427143281839817329423126740566618323641725716448; __sonar=7237334677420142002; __gads=ID=c8b82101a0e4f451:T=1412574724:S=ALNI_MbPMbEOZj2nAGjM54z8ZHFMqwTOTQ; FK-CMP-DATA=; SN=2.VI11FB3FB6ED9D4693A796AB8C965B3417.SI802C325AC43444858830E870C4FD3324.VS141257426735693951472.1412576209; VID=2.VI11FB3FB6ED9D4693A796AB8C965B3417.1412576209.VS141257426735693951472; NSID=2.SI802C325AC43444858830E870C4FD3324.1412576209.VI11FB3FB6ED9D4693A796AB8C965B3417; __utma=19769839.709301254.1412574234.1412574234.1412574234.1; __utmb=19769839.23.10.1412574234; __utmc=19769839; __utmz=19769839.1412574234.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); s_cc=true; gpv_pn=SellerListing%3AMobile%3AMicromax%20Canvas%20Fire%20A093; gpv_pn_t=no%20value; s_sq=%5B%5BB%5D%5D; pincode=110011; s_ppv=36')
-
 
27
        request.add_header('Cache-Control','max-age=0')
-
 
28
        request.add_header('Host','www.flipkart.com')
-
 
29
        request.add_header('User-Agent','Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36')
-
 
30
        response_data = ""
22
        response_data = ""
31
        redirect_url = ""
23
        redirect_url = ""
32
        try:
24
        try:
33
            req = urllib2.Request(url,headers=headers)
25
            req = urllib2.Request(url,headers=headers)
34
            response = urllib2.urlopen(req)
26
            response = urllib2.urlopen(req)
35
            response_data = response.read()
27
            response_data = response.read()
-
 
28
            response.close()
36
            print "Fetched response from flipkart for %s" %(url)
29
            print "Fetched response from flipkart for %s" %(url)
37
            redirect_url = response.url
30
            redirect_url = response.url
38
 
31
 
39
        except Exception as e:
32
        except Exception as e:
40
            print 'ERROR: ', e
33
            print 'ERROR: ', e