chinaz的长尾词挖掘需要付费,有个入口是可以白票到一部分长尾词的,淘小白这里只做了一个简单的小脚本,需要改进的朋友可以自行改进一下,直接上代码:
# -*- coding: utf-8 -*-
'''
@作者 淘小白
@联系QQ 1290654348
@VX:TXB2196
@官网 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