Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bs4 as bs
- import urllib
- from urllib2 import Request, urlopen
- import time
- url = 'https://www.bendix.com.au/catalogue?manufacturer=&model=&variant=&oepart=&part='
- q = Request(url)
- q.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11')
- sauce = urlopen(q).read()
- soup = bs.BeautifulSoup(sauce, 'lxml')
- manufacturers = soup.find_all('select', {"id" : 'edit-manufacturer'})[0]
- manufacturerOptions = manufacturers.find_all('option')
- counter = 0
- for manOption in manufacturerOptions:
- manOptionText = manOption.text
- url = 'https://www.bendix.com.au/catalogue?manufacturer=' + manOptionText + '&model=&variant=&oepart=&part='
- qMan = Request(url)
- qMan.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11')
- src = urlopen(qMan).read()
- srcSoup = bs.BeautifulSoup(src, 'lxml')
- models = soup.find_all('select', {'id': 'edit-model'})[0]
- modelOptions = models.find_all('option')
- for modelOption in modelOptions:
- if(modelOption.text != "Select a Model"):
- print("Manufacturer: " + manOption.text + " " + "Model: " + modelOption.text)
- counter += 1
- print counter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement