批量链接自动推送和周推送

import requests, time


def postbaidu_week(url):
    try:
        html = requests.post("周级收录API接口",
                             data=url,
                             timeout=5).json()
        if html['success'] > 0:
            print("成功推送.........{}".format(html))
        else:
            print("失败推送........{}".format(html))
    except Exception as e:
        print(e)
        postbaidu_week(url)


def pingandpostbaidu(url):
    try:

        html = requests.post("主动推送api接口",
                             data=url,
                             timeout=5).json()
        if html['success'] > 0:
            print("成功推送.........{}".format(html))
        else:
            print("失败推送........{}".format(html))

        # 同时推送至周推送
        postbaidu_week(url)

    except Exception as e:
        print(e)
        pingandpostbaidu(url)

if __name__ == '__main__':

    for url in open("未收录.txt",encoding='utf-8', newline='').readlines():
        pingandpostbaidu(url.strip())

 

posted @ 2019-07-30 15:30  Mana66ccff  阅读(210)  评论(0编辑  收藏  举报