Node. js crawls Douban data and node. js crawls Douban data.
I have always thought that my vue is okay, and I have always thought that my webpack is okay. Today, when I visited node in MOOC, I found that I am still far away. As we all know, vue-cli is based on webpack, while webpack is based on node, so we don't know much about node and what we know about webpack. So I gave myself a question and crawled the Douban data. It is still in its infancy. Today, let's talk about the data crawled from Douban and show it on another page in our own way. We will follow up later.
1. Problems to be Solved
1. Build services
②. How to process crawled data
③ How to automatically open the default browser
2. Build services
There are several ways to build services. At first I used http, but the disadvantage of http is that it cannot parse the https url, so I used express, I used the request package to parse the https protocol. The URL of Douban is https,
The crawler crawled today is.
3. How to process crawled data
How can we process the data that we crawled using the request? The cheerio package allows us to process crawled html data like Jq.
1. parse the data and obtain the html data of the crawled webpage;
② Use the cheerio package to operate the crawled data and obtain the data you want.
③ Obtain the data, Create html, and output the data to the page. For example, the method for concatenating strings is a bit stupid and there is no better way yet.
4. How to automatically open the default browser
I wonder if you have checked the webpack configuration in vue-cli and opened the browser automatically.
This package is very convenient to use. Introduce the package and directly call the UDF (url;
5. Presentation
Follow the Public Accounts