Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. try:
  2. print "what"
  3. newClassName = CourseNameAndCodeAssociation.objects.get(departmentCode__iexact = nameAndNumberStore[0])
  4. print newClassName
  5. except:
  6. print "HAHA"
  7.  
  8. def newGetAllInformation(searchTerm):
  9. nameAndNumberStore = modifySearchTerm(searchTerm)
  10. urlStore = modifyUrl(nameAndNumberStore) # need to make the change here -- why not I go to the site, check for Course name - if that is not there switch, if it is then scrape
  11. soup = getHtml(urlStore)
  12. storeOfBooks = []
  13. storeOfBooks = scrape(soup,nameAndNumberStore)
  14. print nameAndNumberStore[0]
  15. try:
  16. newClassName = CourseNameAndCodeAssociation.objects.get(departmentCode__iexact = nameAndNumberStore[0])
  17. nameAndNumberStore = modifySearchTerm(newClassName.departmentName + " " + nameAndNumberStore[1])
  18. urlStore = modifyUrl(nameAndNumberStore)
  19. soup = getHtml(urlStore)
  20. storeOfBooks = scrape(soup,nameAndNumberStore)
  21.  
  22. except:
  23. print "HAHA"
  24.  
  25. return storeOfBooks
  26.  
  27. try:
  28. print "what"
  29. newClassName = CourseNameAndCodeAssociation.objects.get(departmentCode__iexact = nameAndNumberStore[0])
  30. print newClassName
  31. except Exception as e:
  32. print "HAHA"
  33. print e
  34.  
  35. except CourseNameAndCodeAssociation.DoesNotExist:
  36.  
  37. department_code = name_and_number_store[0]
  38. class_names = CourseNameAndCodeAssociation.objects.all()
  39. try:
  40. new_class_name = class_names.get(departmentCode__iexact=department_code)
  41. except CourseNameAndCodeAssociation.DoesNotExist:
  42. print "HAHA"
  43. else:
  44. search_term = u'%s %s' % (new_class_name.departmentName,
  45. name_and_number_store[1])
  46. name_and_number_store = modify_search_term(search_term)
  47. url_store = modify_url(name_and_number_store)
  48. soup = get_html(url_store)
  49. store_of_books = scrape(soup, name_and_number_store)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement