• 获取百度指数


    1.安装包

    pip3.6 install baidux -i https://mirrors.aliyun.com/pypi/simple
    

    2.简单使用

    from baidux.utils import test_cookies
    from baidux import config
    from baidux import BaiduIndex, ExtendedBaiduIndex
    
    cookies = "BIDUPSID=EE4BED76E820B7B3403DA93994A365E1; PSTM=1594718373; BAIDUID=693B193599DCA13EC8520F6F01AC7C04:FG=1; BD_UPN=12314753; __yjs_duid=1_4578fac6f8ea7c2a886ba3d6949dab691614150686288; BDUSS=mEwRW9sWk53bTJZVDJhYXh5Z0tNS1RYaEM5NWpHQXdORjQ2aXFHaWdmYUM5WEJnSVFBQUFBJCQAAAAAAAAAAAEAAABk7r44c2t5yti7pMq9tci0~QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIJoSWCCaElgV; BDUSS_BFESS=mEwRW9sWk53bTJZVDJhYXh5Z0tNS1RYaEM5NWpHQXdORjQ2aXFHaWdmYUM5WEJnSVFBQUFBJCQAAAAAAAAAAAEAAABk7r44c2t5yti7pMq9tci0~QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIJoSWCCaElgV; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; MCITY=-179%3A; H_PS_PSSID=33517_33344_31253_33691_33595_33675_33392_33618_26350; H_PS_645EC=08faH%2FPByKuX1lHni6eq2hQtlhNuyqRceq4HcZVKJxk7AWTRrWTpQrU4%2FUtbwhQw51TR; COOKIE_SESSION=54746_0_9_0_110_18_1_0_9_9_1_0_54741_0_8_0_1615860749_0_1615860741%7C9%230_0_1615860741%7C1; BD_HOME=1; BA_HECTOR=2l0h2hah01250l20v91g505840r"
    
    # 测试cookies是否配置正确
    # True为配置成功,False为配置不成功
    print(test_cookies(cookies))
    
    keywords = [['英雄联盟'], ['冠军杯', '英雄联盟'], ['抑郁', '自杀', '明星']]
    
    # 获取城市代码, 将代码传入area可以获取不同城市的指数, 不传则为全国
    # 媒体指数不能分地区获取
    print(config.PROVINCE_CODE)
    print(config.CITY_CODE)
    
    # 获取百度搜索指数(地区为山东)
    baidu_index = BaiduIndex(
        keywords=keywords,
        start_date='2018-01-01',
        end_date='2019-01-01',
        cookies=cookies,
        area=901
    )
    for index in baidu_index.get_index():
        print(index)
    
    # 获取百度媒体指数
    news_index = ExtendedBaiduIndex(
        keywords=keywords,
        start_date='2018-01-01',
        end_date='2019-01-01',
        cookies=cookies,
        kind='news'
    )
    for index in news_index.get_index():
        print(index)
    
    # 获取百度咨询指数
    feed_index = ExtendedBaiduIndex(
        keywords=keywords,
        start_date='2018-01-01',
        end_date='2019-01-01',
        cookies=cookies,
        kind='feed'
    )
    for index in feed_index.get_index():
        print(index)
    

      

  • 相关阅读:
    Penetration Test
    SpringBoot启动时初始化数据库及spring.jpa.generate-dll与spring.jpa.hibernate.ddl-auto之间的困惑
    maven deploy到ftp服务器
    spring-boot:repackage生成的MANIFEST.MF中的Main-Class和Start-Class
    @GeneratedValue的strategy
    mysql方言设置
    jpa.generate-ddl和jpa.hibernate.ddl-auto
    在家学习VS在咖啡馆学习
    StatusLogger No Log4j 2 configuration file found
    tomcat应用部署顺序
  • 原文地址:https://www.cnblogs.com/yoyo1216/p/14541996.html
Copyright © 2020-2023  润新知