示例#1
0
 def get_person_data(bs_data):
     try:
         personDatas = {
             "salenums": fix_nums(
                 bs_data.select_one(
                     ".v_table_2 tr:nth-child(3) > td:nth-child(4)"
                 ).text
             ),
             "totalsales": float_format(
                 bs_data.select_one(
                     ".v_table_2 tr:nth-child(5) > td:nth-child(4)"
                 ).text
             ),
             "totalbuys": float_format(
                 bs_data.select_one(
                     ".v_table_2 tr:nth-child(7) > td:nth-child(4)"
                 ).text
             ),
         }
         username = bs_data.select_one(
             ".v_table_2 tr:nth-child(3) > td:nth-child(2)"
         ).text
         debug(f"personDatas: {personDatas}")
         debug(f"username: {username}")
         return personDatas, username
     except Exception as e:
         error(f"[Parser->get_person_data]: {e}")
         return {"salenums": 0, "totalsales": 0, "totalbuys": 0}, ""
示例#2
0
    def get_details(bs_data, current_year, real_up_time, muti):
        try:

            priceUSDT = float_format(
                bs_data.select_one(
                    "tr:nth-child(3) > td:nth-child(4) > span").text)
            priceBTC = float_format(
                bs_data.select_one(
                    "tr:nth-child(5) > td:nth-child(4)").text.split()[0])

            if priceBTC > priceUSDT:
                priceUSDT, priceBTC = priceBTC, priceUSDT

            return debug({
                "lasttime":
                moment.date(f"{current_year} " + bs_data.select_one(
                    "tr:nth-child(7) > td:nth-child(6)").text).format(
                        "YYYY-MM-DD HH:mm:ss"),
                "priceUSDT":
                priceUSDT,
                "priceBTC":
                priceBTC,
                "lines":
                muti["lines"],
                "uptime":
                real_up_time.format("YYYY-MM-DD HH:mm:ss"),
                "hot":
                muti["hot"],
                "types":
                bs_data.select_one("tr:nth-child(5) > td:nth-child(2)").text,
                "status":
                bs_data.select_one("tr:nth-child(7) > td:nth-child(2)").text,
                "oversell":
                fix_nums(
                    bs_data.select_one(
                        "tr:nth-child(9) > td:nth-child(2)").text,
                    to=99999,
                ),
                "sold":
                fix_nums(
                    bs_data.select_one(
                        "tr:nth-child(7) > td:nth-child(4)").text,
                    to=99999,
                ),
            })
        except Exception as e:
            error(f"[Parser->get_details]: {e}")
            raise e