Created
January 20, 2020 13:28
-
-
Save ahmedbesbes/aeee8a10c4a43c7d0c05b0683aef3d48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = {} | |
soup = get_soup(base_url + '/categories') | |
for category in soup.findAll('div', {'class': 'category-object'}): | |
name = category.find('h3', {'class': 'sub-category__header'}).text | |
name = name.strip() | |
data[name] = {} | |
sub_categories = category.find('div', {'class': 'sub-category-list'}) | |
for sub_category in sub_categories.findAll('div', {'class': 'child-category'}): | |
sub_category_name = sub_category.find('a', {'class': 'sub-category-item'}).text | |
sub_category_uri = sub_category.find('a', {'class': 'sub-category-item'})['href'] | |
data[name][sub_category_name] = sub_category_uri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment