本文信息本文由方法SEO顾问发表于2016-10-1316:16:34,共 1733 字,转载请注明:【Python工具】ASO100导出竞争对手的所有关键词数据_【方法SEO顾问】,如果我网站的文章对你有所帮助的话,来百度口碑给个好评呗!
ASO100非VIP账户的话,每天只有5次导出竞争对手的所有关键词数据的机会。于是自己写了个Python脚本来实现了批量导出功能,突破限制。共享出来,或者能帮助到一些做
效果
效果如下图,关键词、排名、指数、结果数
源代码
源代码如下,用得着的可以拿走。
#!/usr/local/bin/python
# -*- coding:utf-8 -*-
######ASO100导出竞争对手的所有关键词数据
######作者:方法
######博客:http://seofangfa.com
######时间:2016-10-13
import re
import os
import json
import time,datetime
import requests
import sys
reload(sys)
from lxml import etree
sys.setdefaultencoding('utf-8')
import codecs#为了生成gbk编码的文件
today = datetime.date.today()
headers = {
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding':'gzip, deflate, sdch',
'Accept-Language':'zh-CN,zh;q=0.8',
'AlexaToolbar-ALX_NS_PH':'AlexaToolbar/alx-4.0',
'Cache-Control':'no-cache',
'Cookie':'',###########替换成自己的cookie信息
'DNT':'1',
'Host':'aso100.com',
'Pragma':'no-cache',
'Proxy-Connection':'keep-alive',
'Referer':'http://aso100.com/search?search=51job',
'Upgrade-Insecure-Requests':'1',
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
}
f = open(unicode('APP所有排名导出-%s.txt'%(today),'utf-8'),'w')
c =0
appList = [['智联招聘','488033535'],['58同城','480079300'],['前程无忧','415443644'],['猎聘','540996859'],['拉勾','1021464186'],['boss直聘','887314963'],['中华英才网','647145486'],['脉脉','718659370'],['大街','864602994'],['领英','1052654880']]####竞争对手信息,名称和关键词ID
for i in appList:
c += 1
name = i[0]
ids = i[1]
r = requests.get("http://aso100.com/app/keyword/appid/%s/country/cn"%(ids),headers=headers)
html = r.content#decode("utf-8")
kwsData = eval(re.findall(r'',html)[0])
for i in kwsData:
kws = i[0].decode("unicode-escape")
index = re.sub('#.*','',i[1])
rank = i[2]
comp = i[3]
print kws,index,rank,comp
f.write("%s\t%s\t%s\t%s\n"%(kws,index,rank,comp))
f.flush()
print '关键词数据已经保存到文件:APP所有排名导出-%s.txt'%(today)