Nodeweibo user guide for a simple encapsulation library for node crawling Weibo data, nodenodeweibo

Source: Internet
Author: User

Nodeweibo user guide for a simple encapsulation library for node crawling Weibo data, nodenodeweibo

I. Preface

In July, I had the idea that I would use node to crawl Weibo data, so I simply encapsulated a nodeweibo database. After one year, the function format is changed to the configuration file in the middle of the process. Some other previous projects have also been deprecated to focus more on the front-end and node. js. Occasionally, we can see more than 60 downloads a day. People are constantly using this database, but few downloads are not updated. But yesterday, someone put forward some pertinent suggestions and useful code for the branch of pull request. So I carefully reviewed nodeweibo and released v2.0.3.

Ii. What is nodeweibo?

Nodeweibo: A simple encapsulation of weibo APIs. You can use functions in Node to call weibo APIs.

Github address:

Here is a markdown section. For details, visit

Install: npm install nodeweibo o

3. Supported APIs

Supported APIs:

Currently, all weiboapis are basically supported. Below are some of them. Thanks to xizhonghua of George Mason University for adding this md.

Iv. demo

Copy codeThe Code is as follows:
Var Weibo = require ('.../nodeweibo'); // require ('nodeweibo ') also works if you have installed nodeweibo O via npm
Var setting = require ('./setting. json'); // get setting (appKey, appSecret, etc .)
+ -------------------------------------------------
(1) registered account:
(2) Configure your development account in./setting. json.
(3) understand the authentication mechanism of Weibo, that is, oauth2.0.
(4) 3rd is very important. Make sure you understand this open method.
+ -------------------------------------------------
Initialize weibo before using it
Weibo. init (setting );

+ -------------------------------------------------
Example 1: Enable Weibo Certification
After authentication is enabled, a window will be opened in the browser. The url contains the code parameter.
Note: When running one of the examples, you must comment out another example.
+ -------------------------------------------------
Weibo. authorize ();

+ --------------------------------------------------
Example 2: access_token is required.
(1) read the Weibo open platform API
Such as:,
Write necessary parameters into the jsonParas object.
(2) print the obtained data in the callback.
(3) code is the code obtained in your browser window.
(4) Note: If you run this example, comment out the 1st examples and call the code function once,
Will be updated with the certification. One user has one access_token.
+ ---------------------------------------------------
// Var jsonParas = {
// Code: "the value of your browser's parameter code ",
// Grant_type: "authorization_code"
// Weibo. OAuth2.access _ token (jsonParas, function (data ){
// Console. log (data );

Example 3, get public timeline
/// Set parameters
// Var para = {
// "Source": Weibo. appKey. appKey,
// "Access_token": 'Your access_token here'
/// Get public timeline
// Weibo. Statuses. public_timeline (para, function (data ){
// Console. log (data );

V. Summary

(1) When releasing a package in the current year, try to write all the documents to make it easier for users. This is an attitude.

(2) Since someone uses this package, try to spend some time maintaining the package. At the beginning of this year, someone asked me how to use it.

(3) Learning others' code is a pleasure. The way to appreciate others' work is to improve work efficiency.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.