Beispiel #1
0
def update_price(progress_bar):
    value_progress_bar = 0
    progress_bar.setValue(value_progress_bar)
    player_store.players = []
    for page_index in range(0, 100):
        url = "https://www.futwiz.com/en/fifa19/players?page=" + str(
            page_index)
        query = requests.get(url)
        page = query.content
        html_data = BeautifulSoup(page, features="html.parser")
        rows = html_data.find_all("tr", attrs={"table-row"})
        for row in rows:
            p = Player()
            player = row.find("td", attrs={"player"})
            tds = row.find_all("td", width=True)
            price = None
            for td in tds:
                if td["width"] == "30":
                    price = td.string.strip()
            price = int(price.replace(",", ""))
            if price == 0:
                continue
            ovr = row.find("td", attrs={"ovr"})
            gen = ovr.a.div.div.string
            _type = ovr.a.div["class"][1]
            _type = _type.replace("otherversion19-", "")
            nom = player.find("p", attrs={"name"}).a.b.string
            nom = nom.replace("'", "")
            team = player.find("p", attrs={"team"})
            index = 0
            club = None
            championnat = None
            for string in team.strings:
                if string and (not string.isspace()):
                    if index == 0:
                        club = string
                    if index == 2:
                        championnat = string
                    index += 1
            p.nom = nom
            p.club = club
            p.championnat = championnat
            p.gen = gen
            p._type = _type
            p.price = price
            player_store.players.append(p)
            from model.database import Database
            db = Database()
            db.update_price(nom=nom, price=price, type=_type, gen=gen)
        value_progress_bar += 1
        progress_bar.setValue(value_progress_bar)
Beispiel #2
0
from ui.main_window import Window
from model.database import Database
from model.player import Player
from model.player_store import player_store
from model.my_player_store import my_player_store

app = QApplication(sys.argv)

db = Database()
players = db.get_players()
for player in players:
    new_player = Player()
    new_player.id = player[0]
    new_player.nom = player[1]
    new_player.championnat = player[2]
    new_player.club = player[3]
    new_player.gen = player[4]
    new_player._type = player[5]
    new_player.price = player[6]
    new_player.favorite = player[7]
    player_store.players.append(new_player)
my_player_store.update_from_db()


def main():
    app = QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())