5118获取百度权重词python代码

作者: loooooong 分类: python 发布时间: 2020-08-14 18:46
#!/usr/bin/python
# -*- coding: UTF-8 -*-


import urllib
import urllib.parse
import urllib.request

import json


def get_baidurank_pc(domain, page=1):
    '''
    5118获取百度权重词python代码
    :param domain:
    :param page:
    :return:
    '''
    siyao = '**'
    url = 'http://apis.5118.com/keyword/baidupc'

    headers = {
        'Authorization': siyao,
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }

    dict = {'url': domain,
            'page_index': page
            }

    data = urllib.parse.urlencode(dict).encode('utf-8')
    req = urllib.request.Request(url=url, data=data, headers=headers)
    response = urllib.request.urlopen(req)
    page = response.read().decode('utf-8')
    domin_zhishuci = json.loads(page)
    print('errcode:{}\n errmsg:{}'.format(domin_zhishuci['errcode'],domin_zhishuci['errmsg']))
    return_str='errcode:{}\n errmsg:{}'.format(domin_zhishuci['errcode'],domin_zhishuci['errmsg'])
    domin_zhishuci = domin_zhishuci['data']
    domin_zhishuci['domin'] = domain
    domin_zhishuci['baidupc']=json.dumps(domin_zhishuci['baidupc'])


    return domin_zhishuci,return_str

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

Leave a Reply

Your email address will not be published. Required fields are marked *

专栏推荐