Hi All,
I am trying to scrape data from a site and able to fetch category urls with below loc-
Can anyone please help me to write a function to get the product urls?
I am trying to scrape data from a site and able to fetch category urls with below loc-
def get_soup(url): soup = None try: response = requests.get(url) if response.status_code == 200: html = response.content soup = BeautifulSoup(html, "html.parser") except Exception as exc: print("error::", str(exc)) finally: return soup def get_category_urls(url): soup = get_soup(url) cat_urls = [] try: categories = soup.find('div', attrs={'id': 'menu_oc'}) if categories is not None: for c in categories.findAll('a'): if c['href'] is not None: cat_urls.append(c['href']) except Exception as exc: print("error..", str(exc)) finally: print("category urls::", cat_urls) return cat_urlsNow issue is with fetching the product urls because I have to fetch all product urls from each category (pagination+without pagination) and thus I am not able to proceed.
Can anyone please help me to write a function to get the product urls?