Node crawl the data of the Simple Encapsulation Library Nodeweibo use guide _node.js

Source: Internet
Author: User

First, the preface

Just last December, one idea was to use node to crawl the data of the microblog, so it simply encapsulated a Nodeweibo library. After a year, not how to maintain, midway also changed the function form to the configuration file. Some of the other projects that have been done are offline, in order to be more focused on front-end & Node.js. Occasionally see more than 60 downloads a day, the continuous use of this library, but see a few downloads are not updated. But yesterday, someone pull request this branch, put forward some pertinent suggestions and useful code. So he carefully reviewed the next Nodeweibo, released the v2.0.3 version.

Second, what is Nodeweibo

Nodeweibo: A simple encapsulation of the Weibo API allows you to invoke the microblogging API in the form of functions in node.

GitHub Project Address: Https://

I am here to cut a markdown part of the screenshot, the specific people can go to Https:// to see.

Installation: NPM Install Nodeweibo

Third, the supported API


At present, the basic support for all WEIBOAPI, the following is a partial screenshot; thank George Mason University Xizhonghua Add this MD.

Four, demo

Copy Code code as follows:

var Weibo = require ('.. /..    /nodeweibo '); Require (' Nodeweibo ') also works if your have installed Nodeweibo via NPM

var setting = require ('./setting.json '); Get Setting (Appkey, Appsecret, etc.)



(1) Registered account:

(2) Configures your Development account in./setting.json.

(3) to understand the micro-Bo authentication mechanism that is oauth2.0 authentication principle.

(4) 3rd is important to ensure that you understand this open approach.




initialize Weibo before using it


weibo.init (setting);

Example 1: Open the Micro-blog certification
After authentication is started, a window will open in the browser with the code parameter in the URL
Note: When running one of these examples, you should comment out another example.
Weibo.authorize ();

Example 2: Need to get Access_token
(1) Read microblogging open Platform API
   such as: Http://,
   write the necessary parameters into the Jsonparas object.
(2) print out the obtained data in the callback
(3) code is the code that is obtained from your browser window.
(4) Note: If you run this example, please comment out the 1th example, and the code function is called once,
        will be updated with the certification. A user is a 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 the release of a package, as far as possible to write a full point of the document, so that users will be more convenient; this is an attitude.

(2) Since someone uses this package, try to spend some time to maintain the package, at the beginning of this year, someone asked me how to use the problem.

(3) Learning others ' code is a pleasure; the way to experience others ' work is to improve the efficiency.

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.