Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PySide.QtCore import QObject, QThread, Signal
- import requests
- import bs4
- class Worker(QThread):
- def __init__(self, url, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.trades = 'NODATA'
- self.posts = 'NODATA'
- self.url = url
- self.start()
- def run(self):
- soup = bs4.BeautifulSoup(requests.get(self.url).text)
- self.trades = soup.select('div.stat_box div.value')[0].get_text().replace(',', '')
- self.posts = soup.select('div.stat_box div.value')[1].get_text()
- return self
- class Outpost(QObject):
- finished = Signal(Worker)
- def __init__(self, id64, *args, **kwargs):
- super().__init__(*args, **kwargs)
- worker = Worker('http://www.myurl.com/' + id64)
- self.trades = worker.trades
- self.posts = worker.posts
- self.finished.emit()
- self.finished.connect(worker.quit)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement