Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. import bs4 as bs
  2. import urllib
  3. from urllib2 import Request, urlopen
  4. import time
  5.  
  6.  
  7. url = 'https://www.bendix.com.au/catalogue?manufacturer=&model=&variant=&oepart=&part='
  8.  
  9. q = Request(url)
  10. 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')
  11. sauce = urlopen(q).read()
  12. soup = bs.BeautifulSoup(sauce, 'lxml')
  13.  
  14. manufacturers = soup.find_all('select', {"id" : 'edit-manufacturer'})[0]
  15. manufacturerOptions = manufacturers.find_all('option')
  16.  
  17. counter = 0
  18. for manOption in manufacturerOptions:
  19.     manOptionText = manOption.text
  20.     url = 'https://www.bendix.com.au/catalogue?manufacturer=' + manOptionText + '&model=&variant=&oepart=&part='
  21.     qMan = Request(url)
  22.     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')
  23.     src = urlopen(qMan).read()
  24.     srcSoup = bs.BeautifulSoup(src, 'lxml')
  25.     models = soup.find_all('select', {'id': 'edit-model'})[0]
  26.     modelOptions = models.find_all('option')
  27.     for modelOption in modelOptions:
  28.         if(modelOption.text != "Select a Model"):
  29.             print("Manufacturer: " + manOption.text + " " + "Model: " + modelOption.text)
  30.             counter += 1
  31.             print counter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement