Python批量导出阿里巴巴国际站引流关键词

阿里国际站对于导出我的词(新版引流关键词),每次只能导出前1000条,剩下的无法导出,公司又没买软件的情况下,可以通过Python批量导出关键词。如果你还没安装Python,查看安装教程:Windows10系统安装Python教程 和 Sublime下载及安装教程

非金品城企客户,想不受限制一次性导出My alibaba>数据管家>引流关键词?

#encoding=utf-8
import requests,csv
#post数据需要的URL,需要数据抓包,对照抓包的数据修改
url='https://hz-mydata.alibaba.com/self/.json?action=CommonAction&iName=getKeywordsAndHasP4P&isVip=true&0.23849763853680295&ctoken=sa0n1q4sxduu&dmtrack_pageid=706067210b837fe25da0975516dbb4f36e419f04b0'
#登陆阿里国际后,通过抓包获取cookies和headers数据,对照抓包的数据修改
cookies={'cookie':'ali_apache_id=11.252.143.228.1525138426343.684238.3; t=acb027ac71991c2710570306f17a83a1; gangesweb-buckettest=117.136.41.59.1551181111116.4; cna=OAvTFSqn9xcCAXWITx4fgRfs; uns_unc_f=trfc_i=safcps^5b359p8n^ll6gljhu^1dib2394f; _ga=GA1.2.16018150191.1565886894; sc_g_cfg_f=sc_b_currency=USD&sc_b_locale=en_US&sc_b_site=GLO; acs_usuc_t=acs_rt=74b4ef9a3d0949c0afeeb747b41e3e2a; v=0; acs_rt=112.96.103.33.1570794388357.2; _m_h5_tk=9c5ed02169a77ce5964d5e9ad892d3db_1570804108657; _m_h5_tk_enc=8e0bd6215824fd2ec2798ec358771328; cookie2=1705e8e2ea409267d0c30ef0b55b488a; _tb_token_=335beb8330b6e; _hvn_login=4; last_ltc_icbu_icbu=cHdk; ali_apache_tracktmp=W_signed=Y; xman_us_f=x_locale=zh_CN&x_l=1&last_popup_time=1554084630374&x_user=CN|Lucy|Lu|cgs|201964637&no_popup_today=n; intl_locale=zh_CN; csg=70be04a1; xman_us_t=ctoken=sa0n1q4sxduu&l_source=alibaba&x_user=y+cwBBOfgk3dg2g+sjKHfkA2YOGqqgi5zZrQNZdnO3M=&x_lid=gjgift&sign=y&need_popup=y; intl_common_forever=QayN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/14cL/3ak5R25FZQcc6eBLX7LZAXij3ahdHUcxPTDy26Nq1+pniA71A5EkAYC0cIR6R6XRy9hRU3MtxUIEURso6ZHDw==; l=dBMJwGYRq2I4-VQFBOfwcuIRX-bTPQAfcsPzw4ZCcICPOoC2frhOWZIxS38yCnGVns9BR3oNd224BfLMlyCVvuef9z7Wy_vK3dYh.; isg=BCkpC18_UPhs8WxMVIwp_sbMONVDXjZK0F1d_csciZA4kkGkE0Va-ADEVHYBCrVg'}
headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36'}
#通过for循环构造1到997页的url,也就是翻页
for i in range(1,998):
    #构建post数据,对照抓包的数据修改
    datas={'statisticsType':'month','selected':'3','statisticType':'os','orderBy':'sumShowCnt','orderModel':'desc','pageSize':'10','pageNO':'%d'%i,'keyword':'%dumbbell%'}
    #通过requests模块去获取网页源代码
    html=requests.post(url=url,headers=headers,cookies=cookies,data=datas,timeout=5)
    html=html.json()
    # html=html.text
    # print (html)
    keyword_data=html['value']['keywords']['data']
    for word in keyword_data:
        #曝光次数
        sumShowCnt=word['sumShowCnt']
        #点击量
        sumClickCnt=word['sumClickCnt']
        #搜索热度
        searchPvIndex=word['searchPvIndex']
        # kwAvgSumShowCnt=word['kwAvgSumShowCnt']
        #关键词
        keyword=word['keyword']
        #top曝光
        avgSumShowCnt=word['avgSumShowCnt']
        #竞争度
        gsTpMemberSetCnt=word['gsTpMemberSetCnt']
        #top点击
        avgSumClickCnt=word['avgSumClickCnt']
        #打印数据
        print ('曝光次数'+'%s'%sumShowCnt,'点击量'+'%s'%sumClickCnt,'搜索热度'+'%s'%searchPvIndex,'词'+'%s'%keyword,'top曝光'+'%s'%avgSumShowCnt,'竞争度'+'%s'%gsTpMemberSetCnt,'top点击'+'%s'%avgSumClickCnt)
        word_data=[keyword,sumShowCnt,sumClickCnt,searchPvIndex,gsTpMemberSetCnt,avgSumShowCnt,avgSumClickCnt]
        with open('yinliu_keyword.csv','a+') as f:
            f_csv=csv.writer(f)
            f_csv.writerow(word_data)

关于网页数据抓包
去到引流关键词页面,鼠标单击右键选择检查,,点击引流关键词的第n页等,即可获取异步加载的引流关键词数据

Python批量导出阿里巴巴国际站引流关键词 1

教程来源于:杨百辉博客

小朱笔记

View posts by 小朱笔记
小朱个人博客,生活网络分享,外贸建站,谷歌seo操作分享,B2B优化排名操作分享,资源分享,软件分享,生活分享。https://www.zhudc.com/

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

Scroll to top