Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import requests, bs4, webbrowser, time, json
  2.  
  3.  
  4. #konwesja stringów do "bez znaków polskich"
  5. #wave_obj = sa.WaveObject.from_wave_file("kaching.wav")
  6.  
  7. print(' ')
  8. print(' ')
  9.  
  10. linksList = []
  11. linksListOld = []
  12.  
  13.  
  14.  
  15. zasieg = 100
  16.  
  17. cena_max = 15000
  18.  
  19. cena_min = 1000
  20.  
  21. przedmiot = "mercedes"
  22.  
  23. miasto = "krakow"
  24.  
  25.  
  26. def update_linksList():
  27.  
  28. res = requests.get('https://www.olx.pl/tychy/q-' + przedmiot + '/?search%5Border%5D=created_at%3Adesc&search%5Bfilter_float_price%3Afrom%5D=' + str(cena_min) + '&search%5Bfilter_float_price%3Ato%5D=' + str(cena_max) + '&search%5Bdist%5D=' + str(zasieg))
  29. res.raise_for_status()
  30. noStarchSoup = bs4.BeautifulSoup(res.text, 'html.parser')
  31. type(noStarchSoup)
  32. linksList.clear()
  33. for link in noStarchSoup.find_all('a', class_ = 'marginright5 link linkWithHash detailsLink'):
  34. linksList.append(link.get('href'))
  35.  
  36. linksListOld = linksList.copy()
  37.  
  38. update_linksList()
  39.  
  40. while True:
  41.  
  42. if linksListOld != linksList :
  43.  
  44. webbrowser.open(linksList[0])
  45. name = str(linksList[0])
  46.  
  47. webbrowser.open(linksList[0])
  48.  
  49. linksListOld = linksList.copy()
  50. print("nowa oferta!!!")
  51.  
  52. elif linksListOld == linksList :
  53.  
  54. update_linksList()
  55. print("nie znaleziono nowych ofert : (")
  56.  
  57. else :
  58.  
  59. break
  60.  
  61. time.sleep(45)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement