Skip to content

Instantly share code, notes, and snippets.

@bukowa
Last active March 9, 2019 14:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bukowa/f339a9416f4a50635bd9983234114ae3 to your computer and use it in GitHub Desktop.
Save bukowa/f339a9416f4a50635bd9983234114ae3 to your computer and use it in GitHub Desktop.
path of exile check poe.trade
from dataclasses import dataclass
from bs4 import BeautifulSoup as soup
import requests
from collections import Counter
import time
# python 3.7
# installation:
# pip install bs4 lxml requests
class Bot:
def __init__(self, url):
self.url = url
self.parser = soup(self._get_html(), 'lxml')
@staticmethod
def _get_count(data):
cnt = Counter()
for i, v in enumerate(data):
cnt[v] += 1
return cnt
def _get_html(self, url=None):
return requests.get(url or self.url).content
def _get_all_ign(self):
return [
e.next_element.next_element.next_element.text
for e in
self.parser.findAll('span', 'success label')
]
def parse(self):
self._get_html()
return self._get_count(self._get_all_ign())
@dataclass
class Item:
name: str
price: int
currency: str
url: str
description: str = ''
def __post_init__(self):
self.bot = Bot(self.url)
def get_message(self, seller, amount):
return f'@{seller} Hi, I would like to buy your {self.name} listed for {self.price} ' \
f'{self.currency} in Delve. I will take all {amount} for a total of {self.price * amount} {self.currency}.' \
f'Please dont add me to party, just write that u agree! Thanks!'
@dataclass()
class Search:
items: list
custom_message: str = None
def go(self, more_than=1):
for item in self.items:
data = item.bot.parse()
for nick, amount in data.most_common():
if amount > more_than:
print(item.get_message(nick, amount))
cheap_fossils = [
Item('Aberrant Fossil', 1, 'chisel', 'http://poe.trade/search/kasebusititare',
'More Chaos modifiers, No Lightning modifiers'),
]
sidhebreath_alch = Item('Sidhebreath Paua Amulet ', 1, 'alchemy', 'http://poe.trade/search/hiyutadukasaho')
sidhebreath_fusing = Item('Sidhebreath Paua Amulet ', 1, 'fusing', 'http://poe.trade/search/monamorahonaut')
bound_fossil = Item('Bound Fossil', 1, 'chaos', 'http://poe.trade/search/ahitosiorinisi')
if __name__ == '__main__':
while True:
Search([bound_fossil]).go(2)
print('Done')
break
while True:
Search([
Item('Bound Fossil', 1, 'chaos', 'http://poe.trade/search/ahitosiorinisi'),
Item('Jagged Fossil', 2, 'chaos', 'http://poe.trade/search/iyarararoazaho'),
Item('Bound Fossil', 1, 'chaos', 'http://poe.trade/search/ahitosiorinisi'),
Item('Tangled Fossil', 1, 'chaos', 'http://poe.trade/search/ahitosiorinisi'),
]).go()
time.sleep(15)
print('=================================================================')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment