Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from bs4 import BeautifulSoup
- import urllib.request as urllib
- def category_parser ():
- checkurl = 'http://www.bazos.sk/'
- checkpage = urllib.urlopen(checkurl)
- checksoup = BeautifulSoup(checkpage.read(), "html.parser")
- categories = {}
- for category in checksoup.select(".nadpisnahlavni a"):
- #print(category.getText())
- #print(category['href'])
- subcat_url = category['href']
- checksub = urllib.urlopen(subcat_url)
- checksubsoup = BeautifulSoup(checksub.read(), "html.parser")
- subcategories = checksubsoup.select(".barvaleva a")
- for subcategory in subcategories:
- subcategory = subcategory.getText()
- #print(subcategory)
- categories[subcategory]=category.getText()
- return categories
- #print("\n\n#######")
- #print(category_parser())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement