コード例 #1
0
 def get_uid_and_sid(bs_data):
     try:
         uid = fix_nums(
             bs_data.select_one(
                 ".v_table_2 > tr:nth-child(5) > td:nth-child(2)").text)
         debug(f"uid: {uid}")
         sid = fix_nums(
             bs_data.select_one("tr:nth-child(3) > td:nth-child(2)").text)
         debug(f"sid: {sid}")
         return uid, sid
     except Exception as e:
         error(f"[Parser->get_uid_and_sid]: {e}")
         return (None, None)
コード例 #2
0
 def get_type_datas(item):
     try:
         return debug(
             {
                 "lines": fix_nums(
                     item.select_one("td:nth-child(7)").text.replace("天", "")
                 ),
                 "hot": fix_nums(item.select_one("td:nth-child(8)").text),
                 "title": item.select_one("td:nth-child(5)").text,
                 "area": item.select_one("td:nth-child(3)").text,
             }
         )
     except Exception as e:
         error(f"[Parser->get_type_datas]: {e}")
         raise e
コード例 #3
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
コード例 #4
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}, ""