Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3. import csv
  4.  
  5. def load_id_dic():
  6. with open('strings.csv', 'r', newline='') as f:
  7. reader = csv.reader(f, delimiter=',')
  8. id_dic = {row[0]: (row[1]) for row in reader}
  9. return id_dic
  10.  
  11. for k, v in load_id_dic().items():
  12. URL = ('http://poe.trade/search/' + v)
  13.  
  14. headers = {"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'}
  15.  
  16. page = requests.get(URL, headers=headers)
  17.  
  18. soup = BeautifulSoup(page.content, 'html.parser')
  19.  
  20. Title = soup.findAll("tbody",{"id":"item-container-0"})
  21. Price = soup.findAll("span",{"class":"currency"})
  22.  
  23. for container in Title:
  24. title = container["data-name"]
  25. print(title)
  26.  
  27. prices = []
  28. for container in Price[:5]:
  29. price = container["title"]
  30. price = price.replace(' chaos', '')
  31. price = int(price)
  32. prices.append(price)
  33. print(sum(prices) / len(prices))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement