chinaz长尾词挖掘工具,python脚本代码分享 -世界杯365买球

seo工具 07-08 11:19:31
chinaz的长尾词挖掘需要付费,有个入口是可以白票到一部分长尾词的,淘小白这里只做了一个简单的小脚本,需要改进的朋友可以自行改进一下,直接上代码:

# -*- coding: utf-8 -*-

'''

@作者 淘小白
@联系qq 1290654348
@vx:txb2196
@世界杯正规买球app官网 i-uni.cn

'''
import os
import time
import re
import requests
headers ={
    
    'accept': 'application/json, text/javascript, */*; q=0.01',
    'accept-encoding': 'gzip, deflate, br',
    'accept-language': 'zh-cn,zh;q=0.9,en;q=0.8',
    'connection': 'keep-alive',
    'content-length': '29',
    'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
    'cookie': '===============================================换成自己的cookie 保留引号====',
    'host': 'data.chinaz.com',
    'origin': 'https://data.chinaz.com',
    'referer': 'https://data.chinaz.com/ci',
    'sec-ch-ua': '" not a;brand";v="99", "chromium";v="101", "google chrome";v="101"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/101.0.0.0 safari/537.36',
    'x-requested-with': 'xmlhttprequest'
}
def get_chinaz_ci(key):
    url = 'https://data.chinaz.com/pull/allkeyword'
    datas = {
        'keyword': key
    }

    req = requests.post(url,data=datas,headers=headers)
    res = req.text
    ci_ku = re.findall(r'"(.*?)"',res)
    return ci_ku

def write_key(key):
    with open('d:\\淘金网\\chinaz 词库\\待修改_ciku.txt','a ') as f:
        if '带货' in key :
            f.write(key '\n')
            print(key)
        else:
            pass

def get_list_key(key):
    url = 'https://data.chinaz.com/pull/indexkeyword'
    datas = {
        'keyword': key
    }

    req = requests.post(url,data=datas,headers=headers)
    res = req.text
    ci_ku = re.findall(r'"(.*?)"',res)
    return ci_ku


if __name__ == '__main__':


    zc_ku = []
    ci_all = []
    key = '新手带货'
    zc_ku.append(key)
    ci_all.append(key)
    while true:
        if len(zc_ku) > 0:
            del_key= zc_ku.pop(0)
            xl_ci = get_chinaz_ci(del_key)
            xg_ci = get_list_key(del_key)
            xg_cis = xl_ci xg_ci
            for i in xg_cis:
                if i not in ci_all:
                    zc_ku.append(i)
                    ci_all.append(i)
                    write_key(i)
                    
                else:
                    pass
            if len(zc_ku)<0:
                break
            else:
                pass
        else:
            print('done!')
            break