Skip to content

RogerLiNing/baidu_index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

baidu_index

Baidu index - fetch data from index.baidu.com/baidu-index-mobile/

Installation

  • pip install baidu_index
  • run pipenv update , pipenv shell and python

A simple use example

from baidu_index import Client

# cookie can be found in browser
# pleas note that you must visit the index website first 
# so the BDUSS will be valid 
# you can neither pass in cookie_str or BDUSS
# to initialize the class

# client = Client(cookie_str="cookie strings")
client = Client(BDUSS="BDUSS")

# query single keyword
result = client.search("IG","20181030","20181105")
print(result)
[{'keyword': 'ig', 'all': {'2018-10-30': '7380', '2018-10-31': '4953', '2018-11-01': '24586', '2018-11-02': '63632', '2018-11-03': '2277074', '2018-11-04': '779939', '2018-11-05': '191029'}, 'pc': {'2018-10-30': '6364', '2018-10-31': '4724', '2018-11-01': '5212', '2018-11-02': '7590', '2018-11-03': '161557', '2018-11-04': '62094', '2018-11-05': '39850'}, 'mobile': {'2018-10-30': '1016', '2018-10-31': '229', '2018-11-01': '19374', '2018-11-02': '56042', '2018-11-03': '2115517', '2018-11-04': '717845', '2018-11-05': '151179'}, 'uniqid': '5be39c1bc9adc7.53480034'}]

# query up to 3 keywords
result = client.search(["IG","WE","RNG"],"20181030","20181105")
print(result)
[{'keyword': 'ig', 'all': {'2018-10-30': '7380', '2018-10-31': '4953', '2018-11-01': '24586', '2018-11-02': '63632', '2018-11-03': '2277074', '2018-11-04': '779939', '2018-11-05': '191029'}, 'pc': {'2018-10-30': '6364', '2018-10-31': '4724', '2018-11-01': '5212', '2018-11-02': '7590', '2018-11-03': '161557', '2018-11-04': '62094', '2018-11-05': '39850'}, 'mobile': {'2018-10-30': '1016', '2018-10-31': '229', '2018-11-01': '19374', '2018-11-02': '56042', '2018-11-03': '2115517', '2018-11-04': '717845', '2018-11-05': '151179'}, 'uniqid': '5be39c4ee9d451.60062121'}, {'keyword': 'we', 'all': {'2018-10-30': '4653', '2018-10-31': '4621', '2018-11-01': '4461', '2018-11-02': '4485', '2018-11-03': '23047', '2018-11-04': '15725', '2018-11-05': '7867'}, 'pc': {'2018-10-30': '1475', '2018-10-31': '1423', '2018-11-01': '1453', '2018-11-02': '1490', '2018-11-03': '3781', '2018-11-04': '2386', '2018-11-05': '2086'}, 'mobile': {'2018-10-30': '3178', '2018-10-31': '3198', '2018-11-01': '3008', '2018-11-02': '2995', '2018-11-03': '19266', '2018-11-04': '13339', '2018-11-05': '5781'}, 'uniqid': '5be39c4ee9d451.60062121'}, {'keyword': 'rng', 'all': {'2018-10-30': '18216', '2018-10-31': '14108', '2018-11-01': '10908', '2018-11-02': '12002', '2018-11-03': '117176', '2018-11-04': '61356', '2018-11-05': '23964'}, 'pc': {'2018-10-30': '6043', '2018-10-31': '5123', '2018-11-01': '3985', '2018-11-02': '3986', '2018-11-03': '22184', '2018-11-04': '10483', '2018-11-05': '8000'}, 'mobile': {'2018-10-30': '12173', '2018-10-31': '8985', '2018-11-01': '6923', '2018-11-02': '8016', '2018-11-03': '94992', '2018-11-04': '50873', '2018-11-05': '15964'}, 'uniqid': '5be39c4ee9d451.60062121'}]

To-do list

  • query baidu index by passing keywords

FAQ

What is 'all','pc','wise'?

all is the sum of pc and wise, wise means mobile devices.

About

爬取百度指数数据

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages