Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- import csv
- def load_id_dic():
- with open('strings.csv', 'r', newline='') as f:
- reader = csv.reader(f, delimiter=',')
- id_dic = {row[0]: (row[1]) for row in reader}
- return id_dic
- for k, v in load_id_dic().items():
- URL = ('http://poe.trade/search/' + v)
- 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'}
- page = requests.get(URL, headers=headers)
- soup = BeautifulSoup(page.content, 'html.parser')
- Title = soup.findAll("tbody",{"id":"item-container-0"})
- Price = soup.findAll("span",{"class":"currency"})
- for container in Title:
- title = container["data-name"]
- print(title)
- prices = []
- for container in Price[:5]:
- price = container["title"]
- price = price.replace(' chaos', '')
- price = int(price)
- prices.append(price)
- print(sum(prices) / len(prices))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement