Jun-29-2018, 05:09 AM
(Jun-28-2018, 11:57 AM)gontajones Wrote: Here bs4 are inserting closing tags before the end of the html source.
So I did this, it's only an idea:
def get_product_details(url): try: soup = get_soup(url) desc_list = [] # Get the product Name before the closing tags inserted by bs4 desc_list.append(soup.select('#detail-right')) start_tag = '<input id="itemPrice1" name="nuPrice1" type="hidden" value=""/>' end_tag = '<div id="qty">' # Loop through tags and append those between start_tag and end_tag flag_append = False for content in soup.findAll(): if(start_tag in str(content)): flag_append = True if(end_tag in str(content)): break if(flag_append): desc_list.append(content.contents) prod_details = {} prod_details['description'] = ''.join([str(i) for i in desc_list]) print(prod_details) return prod_details except Exception as ex: logger.warning('%s - %s', ex, url)
Seems some problem here! When I ran your code, no description is returned for any product!