示例#1
0
def query_pop_income():
    today = datetime.datetime.now().strftime('%Y-%m-%d')
    yestoday = (datetime.datetime.today() + datetime.timedelta(-1)).strftime('%Y-%m-%d')

    today_pop = zhihu_spider.get_jd_order(today, today, zh_config_dao.query_config('jfck2').value)
    today_gmv = 0
    today_order = 0
    for order in today_pop:
        if order['validCodeMsg'] == '已付款' or order['validCodeMsg'] == '已完成' or order['validCodeMsg'] == '已付定金':
            if 'skuShopName' in order and order['estimateCosPrice'] > 500 and order['pid']== '1003111258_4000348996_3004398015':
                if 'Redmi Note 11 Pro' not in order['skuName']:
                    if order['skuShopName'] == 'realme真我官方旗舰店' or order['skuShopName'] == 'iQOO官方旗舰店' or order[
                    'skuShopName'] == '小米手机官方旗舰店' or order['skuShopName'] == 'OPPO官方直营旗舰店' or order[
                    'skuShopName'] == 'vivo官方旗舰店' or order['skuShopName'] == '一加官方旗舰店':
                        today_gmv += order['estimateCosPrice']
                        today_order += 1

    yestoday_pop = zhihu_spider.get_jd_order(yestoday, yestoday, zh_config_dao.query_config('jfck2').value)
    yestoday_gmv = 0
    yestoday_order = 0
    for order in yestoday_pop:
        if order['validCodeMsg'] == '已付款' or order['validCodeMsg'] == '已完成' or order['validCodeMsg'] == '已付定金':
            if 'skuShopName' in order and order['estimateCosPrice'] > 500 and order['pid']== '1003111258_4000348996_3004398015':
                if 'Redmi Note 11 Pro' not in order['skuName']:
                    if order['skuShopName'] == 'realme真我官方旗舰店' or order['skuShopName'] == 'iQOO官方旗舰店' or order[
                    'skuShopName'] == '小米手机官方旗舰店' or order['skuShopName'] == 'OPPO官方直营旗舰店' or order[
                    'skuShopName'] == 'vivo官方旗舰店' or order['skuShopName'] == '一加官方旗舰店':
                        yestoday_gmv += order['estimateCosPrice']
                        yestoday_order += 1

    return "[pop今] GMV:" + str(int(today_gmv)) + " 订单数:" + str(today_order) + " 佣金:" + str(
        int(today_gmv * 0.08)) + "\n[pop昨] GMV:" + str(int(yestoday_gmv)) + " 订单数:" + str(
        yestoday_order) + " 佣金:" + str(int(yestoday_gmv * 0.08))
示例#2
0
def query_jingfen_click():
    today = datetime.datetime.now().strftime('%Y-%m-%d')
    yestoday = (datetime.datetime.today() + datetime.timedelta(-1)).strftime('%Y-%m-%d')

    today_click = zhihu_spider.get_jingfen_click(today, today, zh_config_dao.query_config('jfck2').value)

    yestoday_click = zhihu_spider.get_jingfen_click(yestoday, yestoday, zh_config_dao.query_config('jfck2').value)

    return "[京粉点击数]" + str(today_click) + "/(" + str(yestoday_click) + ")"
示例#3
0
def post_question_draft(qid, content):
    cookie = zh_config_dao.query_config('dxck').value
    result = auto_spider.post_question_draft(qid, content, cookie)

    logger.info('写草稿完成,时间:{}'.format(result['updated_time']))

    return
示例#4
0
def query_zhijia_pay():
    top = "[知+消耗] "

    today = datetime.datetime.now().strftime('%Y-%m-%d')
    pay = zhihu_spider.get_zhijia_pay(today, today, zh_config_dao.query_config('zjck').value)

    return top + str(round(pay/100,2)), pay/100
示例#5
0
def query_zhijia_pay_2():
    top = "[知+] "

    today = datetime.datetime.now().strftime('%Y-%m-%d')
    result, pay = zhihu_spider.get_zhijia_pay_2(today, today, zh_config_dao.query_config('lanmao-zjck').value)

    return top + result, pay/100
示例#6
0
def replace_question_draft_template(qid):
    cookie = zh_config_dao.query_config('dxck').value

    origin_draft = auto_spider.get_question_draft_html(qid, cookie)
    if origin_draft == '接口异常':
        return '找不到原草稿,qid:{}'.format(qid)

    reg = "<p>Auto-.+?</p>"
    pattern = re.compile(reg)
    template_list = re.findall(pattern, origin_draft['content'])
    if len(template_list) == 0:
        logger.info('原草稿内没有模板,qid:{}'.format(qid))
        return '原草稿内没有模板,不处理,qid:{}'.format(qid)

    new_draft_content = origin_draft['content']
    for template in template_list:
        template = template.replace('<p>', '')
        template = template.replace('</p>', '')
        words = template.split('_')

        if len(words) != 2:
            return '模板格式有误,不处理,template:{}'.format(template)

        aid = words[1]
        aids = [aid]

        template_html = query_article_draft_html(aids)

        new_draft_content = new_draft_content.replace(template, template_html)

    result = auto_spider.post_question_draft(qid, new_draft_content, cookie)
    logger.info('写草稿完成,时间:{}'.format(result['updated_time']))

    return '草稿模板替换成功,qid:{},length:{}'.format(qid, len(new_draft_content))
示例#7
0
def query_jingfen_earnings():
    today = datetime.datetime.now().strftime('%Y-%m-%d')

    top1 = "[京粉-1] "
    mid1 = "订单量:"
    end1 = " 佣金:"

    count1, sum1 = zhihu_spider.get_jingfen_earnings(today, today, zh_config_dao.query_config('jfck1').value)

    top2 = "[京粉-2] "
    mid2 = "订单量:"
    end2 = " 佣金:"

    count2, sum2 = zhihu_spider.get_jingfen_earnings(today, today, zh_config_dao.query_config('jfck2').value)

    return top1 + mid1 + str(count1) + end1 + str(sum1), sum1, top2 + mid2 + str(count2) + end2 + str(sum2), sum2
示例#8
0
def query_article_draft_html(aid_list):
    cookie = zh_config_dao.query_config('dxck').value
    result = ''
    for aid in aid_list:
        draft_content = auto_spider.get_article_draft_html(aid, cookie)
        result += draft_content

    return result
示例#9
0
def query_jingfen_redpacket():
    today = datetime.datetime.now().strftime('%Y-%m-%d')

    top2 = "[京粉-2] "
    mid2 = "红包点击:"
    end2 = " 红包发放:"

    show, give = zhihu_spider.get_jingfen_redpacket(today, today, zh_config_dao.query_config('jfck2').value)

    return top2 + mid2 + str(show) + end2 + str(give)
示例#10
0
def query_zhihu_earnings_2():
    today = datetime.datetime.now().strftime('%Y-%m-%d')

    top1 = "[知乎猫叔] "
    mid1 = "订单量:"
    end1 = " 佣金:"

    count1, sum1, gmv = zhihu_spider.get_zhihu_earnings(today, today, zh_config_dao.query_config('maoshu-ck').value)

    return top1 + mid1 + str(count1) + end1 + str(sum1/100), sum1/100
示例#11
0
def query_article_draft():
    cookie = zh_config_dao.query_config('dxck').value
    draft_all = auto_spider.get_article_draft_all(cookie)

    result = []
    for i, item in enumerate(draft_all):
        if item['title'].startswith('Auto-'):
            tmp = "【{}】{}_{}".format(i + 1, item['title'], item['id'])
            result.append(tmp)

    result.sort()

    return result
示例#12
0
def query_brand_order(brand):
    today = datetime.datetime.now().strftime('%Y-%m-%d')
    yestoday = (datetime.datetime.today() + datetime.timedelta(-1)).strftime('%Y-%m-%d')

    brandName = 'xxx'
    if brand == 'oppo':
        brandName = 'OPPO京东自营官方旗舰店'
    elif brand == 'vivo':
        brandName = 'vivo京东自营官方旗舰店'

    today_orders = zhihu_spider.get_jd_order(today, today, zh_config_dao.query_config('jfck2').value)

    today_gmv = 0
    today_order = 0
    today_order_detail = ''
    for order in today_orders:
        if order['validCodeMsg'] == '已付款' or order['validCodeMsg'] == '已完成' or order['validCodeMsg'] == '已付定金':
            if 'skuShopName' in order and order['estimateCosPrice'] > 500:
                if order['skuShopName'] == brandName:
                    today_gmv += order['estimateCosPrice']
                    today_order += 1
                    today_order_detail += str(today_order) + '、' + order['skuName'] + '\n'

    yestoday_orders = zhihu_spider.get_jd_order(yestoday, yestoday, zh_config_dao.query_config('jfck2').value)
    yestoday_gmv = 0
    yestoday_order = 0
    yestoday_order_detail = ''
    for order in yestoday_orders:
        if order['validCodeMsg'] == '已付款' or order['validCodeMsg'] == '已完成' or order['validCodeMsg'] == '已付定金':
            if 'skuShopName' in order and order['estimateCosPrice'] > 500:
                if order['skuShopName'] == brandName:
                    yestoday_gmv += order['estimateCosPrice']
                    yestoday_order += 1
                    yestoday_order_detail += str(yestoday_order) + '、' + order['skuName'] + '\n'

    return "[今日数据]\nGMV:" + str(int(today_gmv)) + "\n订单数:" + str(today_order) + "\n订单明细\n" + str(today_order_detail) + "\n\n[昨日数据]\nGMV:" + str(int(yestoday_gmv)) + "\n订单数:" + str(yestoday_order) + "\n订单明细\n" + str(yestoday_order_detail)
示例#13
0
def query_today_order():
    today = datetime.datetime.now().strftime('%Y-%m-%d')

    today_orders = zhihu_spider.get_jd_order(today, today, zh_config_dao.query_config('jfck2').value)

    today_order = 0
    today_money = 0
    today_order_detail = ''
    for order in today_orders:
        if order['validCodeMsg'] == '已付款' or order['validCodeMsg'] == '已完成' or order['validCodeMsg'] == '已付定金':
            if 'skuShopName' in order and order['estimateCosPrice'] > 500:
                today_order += 1
                today_money += round(order['estimateCosPrice'] * order['commissionRate'] * 0.007, 1)
                
                today_order_detail += str(today_order) + '、【' + str(round(order['estimateCosPrice'] * order['commissionRate'] * 0.007, 1)) + '】\n金额:' + str(order['estimateCosPrice'])+ ', 比例:' + str(order['commissionRate']) + '%,[' + order['skuName'][0:20] + ']\n'

    return "[今日订单]\n订单数:" + str(today_order) + " 预估佣金:" + str(today_money)+ "\n订单明细\n" + str(today_order_detail)
示例#14
0
def query_pop_income_all():
    begin = '2022-04-21'
    end = '2022-05-30'

    total_pop = zhihu_spider.get_jd_order(begin, end, zh_config_dao.query_config('jfck2').value)
    total_gmv = 0
    total_order = 0
    for order in total_pop:
        if order['validCodeMsg'] == '已付款' or order['validCodeMsg'] == '已完成':
            if 'skuShopName' in order and order['estimateCosPrice'] > 500 and order['pid']== '1003111258_4000348996_3004398015':
                if 'Redmi Note 11 Pro' not in order['skuName']:
                    if order['skuShopName'] == 'realme真我官方旗舰店' or order['skuShopName'] == 'iQOO官方旗舰店' or order[
                        'skuShopName'] == '小米手机官方旗舰店' or order['skuShopName'] == 'OPPO官方直营旗舰店' or order[
                        'skuShopName'] == 'vivo官方旗舰店' or order['skuShopName'] == '一加官方旗舰店':
                        total_gmv += order['estimateCosPrice']
                        total_order += 1

    return "[pop总] GMV:" + str(int(total_gmv)) + " 订单数:" + str(total_order) + " 佣金:" + str(int(total_gmv * 0.08))
示例#15
0
def query_zhihu_earnings():
    today = datetime.datetime.now().strftime('%Y-%m-%d')

    top1 = "[知乎-1] "
    mid1 = "订单量:"
    end1 = " 佣金:"
    end11 = " 比例:"

    count1, sum1, gmv1 = zhihu_spider.get_zhihu_earnings(today, today, zh_config_dao.query_config('dxck').value)

    top2 = "[知乎-2] "
    mid2 = "订单量:"
    end2 = " 佣金:"

    count2, sum2, gmv2 = 0, 0, 0
    # count2, sum2, gmv2 = zhihu_spider.get_zhihu_earnings(today, today, zh_config_dao.query_config('lsck').value)

    rate = ''
    if gmv1 > 0:
        rate = str(round(sum1 / gmv1 * 100, 2))

    return top1 + mid1 + str(count1) + end1 + str(sum1 / 100) + end11 + rate, sum1 / 100, top2 + mid2 + str(
        count2) + end2 + str(sum2 / 100), sum2 / 100
示例#16
0
    return json['total']['cost']

# 调知+ api 查询账户今日消耗
def get_zhijia_pay_2(start, end, cookie):
    # 知+ API
    url = '''
        https://xg.zhihu.com/api/v1/stat/overview?userId=504360&dataType=USER&groupUnit=BY_HOUR&stTms={}&endTms={}
    '''.format(start, end)
    header = {
        'cookie': cookie,
        'referer': 'https://xg.zhihu.com/advertiser/504360/home',
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15'
    }

    try:
        res = requests.get(url, headers=header)
        res.encoding = 'utf-8'
    except BaseException as e:
        return "接口异常"

    json = res.json()

    return '花费:' + str(format(json['total']['cost']/100,'.1f')) + ' 点击:' + str(json['total']['click']) + ' 点击率:' + str(format(json['total']['clickRate']*100,'.1f')) + '%', json['total']['cost']


if __name__ == "__main__":
    today = '2022-04-30'
    cookie = zh_config_dao.query_config('jfck2').value
    print(get_jd_order(today, today, cookie))
示例#17
0
def query_today_data_2():
    return zhihu_spider.get_zhihu_card_data(zh_config_dao.query_config('maoshu-ck').value)
示例#18
0
        "cookie": cookie,
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
        'referer': "https://www.zhihu.com/question/{}/?write".format(qid),
        'content-type': 'application/json',
    }

    body = {
        "content": content,
        "delta_time": 3,
        "draft_type": "normal",
    }

    try:
        res = requests.post(url, data=json.dumps(body), headers=header)
        res.encoding = 'utf-8'
    except BaseException:
        return "接口异常"

    if res.status_code != 200:
        logger.info(res.text)
        return "接口异常"

    logger.info("保存回答草稿成功,qid:{}".format(qid))

    return res.json()


if __name__ == "__main__":
    cookie = zh_config_dao.query_config('dxck').value
    print(get_article_draft_html(508568552, cookie))