Subversion Repositories SmartDukaan

Rev

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

Rev 14167 Rev 14169
Line 44... Line 44...
44
 
44
 
45
            if self.count_trials < 3:
45
            if self.count_trials < 3:
46
                return self.read(url)
46
                return self.read(url)
47
 
47
 
48
        self.response_data=response_data
48
        self.response_data=response_data
49
        return self.createSoup(url,redirect_url)
49
        return self.createSoup(url)
50
    
50
    
51
    
51
    
52
    def createSoup(self,url, redirect_url):
52
    def createSoup(self,url):
53
        print "Creating soup from flipkart data for %s" %(url)
53
        print "Creating soup from flipkart data for %s" %(url)
54
        page=self.response_data.decode("utf-8")
54
        page=self.response_data.decode("utf-8")
55
        self.soup = BeautifulSoup(page,convertEntities=BeautifulSoup.HTML_ENTITIES)
55
        self.soup = BeautifulSoup(page,convertEntities=BeautifulSoup.HTML_ENTITIES)
56
        print "Soup created from flipkart data for %s" %(url)
56
        print "Soup created from flipkart data for %s" %(url)
57
        return self.scrape(self.soup,url)
57
        return self.scrape(self.soup)
58
 
58
 
59
    def scrape(self,soup,url):
59
    def scrape(self,soup):
60
        try:
60
        try:
61
            print "data-config"
61
            print "data-config"
62
            if soup.find('div',{'class':'seller-table-wrap section'}) is None:
62
            if soup.find('div',{'class':'seller-table-wrap section'}) is None:
63
                raise
63
                raise
64
            x = json.loads(soup.find('div',{'class':'seller-table-wrap section'})['data-config'])['dataModel']
64
            x = json.loads(soup.find('div',{'class':'seller-table-wrap section'})['data-config'])['dataModel']