Ejemplo n.º 1
0
    def retrieve_product_data(self, product_link):
        browser = mechanize.Browser()
        product_data = browser.open(product_link).get_data()

        try:
            product_soup = BeautifulSoup(product_data)
        except UnicodeEncodeError:
            return None

        name = product_soup.find('div', {'class': 'titleContent'}).string
        name = name.encode('ascii', 'ignore')

        try:
            availability = product_soup.find('div', {'class': 'stock'})
            availability = availability.contents[4]
        except AttributeError:
            return None

        if 'Agotado' in availability:
            return None

        cash_price = product_soup.findAll('div', {'class': 'precioDetalle'})[-1]
        cash_price = cash_price.string.split('$')[1]
        cash_price = int(clean_price_string(cash_price))

        part_number = product_soup.find('div', { 'class': 'codProduct' }).string.replace('[', '').replace(']', '').encode('ascii', 'ignore').strip()

        product_data = ProductData()
        product_data.custom_name = name
        product_data.price = cash_price
        product_data.url = product_link
        product_data.comparison_field = product_link
        product_data.part_number = part_number
        
        return product_data
Ejemplo n.º 2
0
    def retrieve_product_data(self, product_link):
        browser = mechanize.Browser()
        product_data = browser.open(product_link).get_data()
        product_soup = BeautifulSoup(product_data)

        try:
            name = product_soup.find('th', {'colspan': '2'}).string
        except AttributeError:
            return None
        name = name.encode('ascii', 'ignore').split('"')[1]

        prices = {}

        cash_price = product_soup.find('table', {
            'cellspacing': '1'
        }).find('table')
        cash_price = cash_price.findAll('td')[3].find('strong').string
        cash_price = int(clean_price_string(cash_price))

        for p in ['cash', 'deposit', 'wire_transfer']:
            prices[p] = cash_price
        product_data = ProductData()
        product_data.custom_name = name
        product_data.price = cash_price
        product_data.url = product_link
        product_data.comparison_field = product_link

        return product_data
Ejemplo n.º 3
0
    def retrieve_product_data(self, product_link):
        browser = mechanize.Browser()
        product_data = browser.open(product_link).get_data()
        product_soup = BeautifulSoup(product_data)

        try:
            name = product_soup.find('th', {'colspan': '2'}).string
        except AttributeError:
            return None
        name = name.encode('ascii', 'ignore').split('"')[1]

        prices = {}

        cash_price = product_soup.find('table',
                {'cellspacing': '1'}).find('table')
        cash_price = cash_price.findAll('td')[3].find('strong').string
        cash_price = int(clean_price_string(cash_price))

        for p in ['cash', 'deposit', 'wire_transfer']:
            prices[p] = cash_price
        product_data = ProductData()
        product_data.custom_name = name
        product_data.price = cash_price
        product_data.url = product_link
        product_data.comparison_field = product_link
        
        return product_data
Ejemplo n.º 4
0
    def retrieve_product_data(self, product_link):
        try:
            product_webpage = mechanize.urlopen(product_link)
        except HTTPError:
            return None

        product_soup = BeautifulSoup(product_webpage.read())

        try:
            product_name = product_soup.find('h1', {
                'id': 'catalog_link'
            }).string
        except AttributeError:
            return None
        product_name = product_name.strip().encode('ascii', 'ignore')

        # Product not available check
        if product_soup.find('span', 'button_bottom'):
            return None

        product_price = product_soup.find('span', {'id': 'offerPrice'}).string
        product_price = int(clean_price_string(product_price))

        product_data = ProductData()
        product_data.custom_name = product_name
        product_data.url = product_link
        product_data.price = product_price
        product_data.comparison_field = product_link

        return product_data
Ejemplo n.º 5
0
    def retrieve_product_data(self, productUrl):
        br = mechanize.Browser()
        data = br.open(productUrl).get_data()
        soup = BeautifulSoup(data)

        try:
            title = soup.find('span', 'para_intropara').string
        except AttributeError:
            try:
                title = soup.find('div', {
                    'id': 'scpcc_title'}).find('img')['alt']
            except AttributeError:
                return None

        title = title.encode('ascii', 'ignore')

        price = soup.find(['tr', 'td'], {'class': 'pricing_dotdotdot'})
        price = price.findAll('span')[-1].string.split('$')[1]
        price = int(clean_price_string(price))

        prices = {}
        for p in ['credit_card', 'deposit', 'wire_transfer']:
            prices[p] = price
        productData = ProductData()

        productData.custom_name = title
        productData.price = price
        productData.url = productUrl
        productData.comparison_field = productData.url

        return productData
Ejemplo n.º 6
0
    def retrieve_product_data(self, product_link):
        browser = mechanize.Browser()
        product_data = browser.open(product_link).get_data()
        soup = BeautifulSoup(product_data)

        name = soup.findAll('h2')[1]
        name = name.string.strip().encode('ascii', 'ignore')

        price = soup.find('span', {'itemprop': 'price'}).contents[0]
        price = int(clean_price_string(price))

        product_data = ProductData()
        product_data.custom_name = name
        product_data.price = price
        product_data.url = product_link
        product_data.comparison_field = product_link

        return product_data
Ejemplo n.º 7
0
    def retrieve_product_data(self, product_link):
        browser = mechanize.Browser()
        product_data = browser.open(product_link).get_data()

        try:
            product_soup = BeautifulSoup(product_data)
        except UnicodeEncodeError:
            return None

        name = product_soup.find('div', {'class': 'titleContent'}).string
        name = name.encode('ascii', 'ignore')

        try:
            availability = product_soup.find('div', {'class': 'stock'})
            availability = availability.contents[4]
        except AttributeError:
            return None

        if 'Agotado' in availability:
            return None

        cash_price = product_soup.findAll('div',
                                          {'class': 'precioDetalle'})[-1]
        cash_price = cash_price.string.split('$')[1]
        cash_price = int(clean_price_string(cash_price))

        part_number = product_soup.find('div', {
            'class': 'codProduct'
        }).string.replace('[', '').replace(']', '').encode('ascii',
                                                           'ignore').strip()

        product_data = ProductData()
        product_data.custom_name = name
        product_data.price = cash_price
        product_data.url = product_link
        product_data.comparison_field = product_link
        product_data.part_number = part_number

        return product_data
Ejemplo n.º 8
0
    def retrieve_product_data(self, product_link):
        browser = mechanize.Browser()
        try:
            product_soup = BeautifulSoup(browser.open(product_link).get_data())
        except Exception:
            return None

        name = product_soup.find('h1').contents[0].encode('ascii', 'ignore')
        name = name.strip()

        prices = {}

        cash_price = product_soup.findAll('h2')[1].string.replace('cash', '')
        cash_price = int(clean_price_string(cash_price))

        product_data = ProductData()
        product_data.custom_name = name
        product_data.price = cash_price
        product_data.url = product_link
        product_data.comparison_field = product_link

        return product_data