baidu-search
v1.3.0
Published
module to conduct search in http://www.baidu.com
Downloads
4
Readme
Objective
module to conduct search in http://www.baidu.com
About baidu
baidu (http://www.baidu.com) is the largest search engine in China, it's google's equivalent here. It provide not only serach engine, but also Wikipedia like knowledge sharing, social networking, etc.
How to test this lib
This lib is based on TDD (Test Driven Development), so you can look at the test cases first, which is the file ./test/unittest.js
, you can run the test as below
cd ./test/
node unittest.js
If there are failures, you'll see Assert Excpetioin, below is one sample. Otherwise, no errors means all tests passed.
assert.js:90
throw new assert.AssertionError({
^
AssertionError: false == true
at /Users/todzhang/dev/git/baidu-search/test/unittest.js:50:2
at Request._callback (/Users/todzhang/dev/git/baidu-search/baidu.js:60:9)
xxxxx
How to use this lib
Firstly if not, please firstly load this library via npm , for example
npm install baidu-search -save
Secondly, you should import this library in your source and then you can use following approaches to start a search:
var baidu = require('baidu-search')
baidu('Microsoft',((err,res)=>{
console.log('Get title of first matched result,标题是:'+res.links[0].title)
console.log('Get link of second matched result,链接是:'+res.links[1].link)
console.log('print all matched results,如下是所有链接:')
res.links.forEach(function(item,idx){
console.log(' title :'+ item.title)
})
}))
How to contact me
You can find my contact via npm listed email or wechat at helloworld_2000