Batch download of network pictures based on Java

Yesterday, a friend met a demand for a project. He needed to download thousands of microblog expression pictures to the local disk, make standard naming, and plug me a pile of JSON data. Let me help deal with it. Anyway, I have nothing to do at leisure, so I helped write it. (it's a very simple function. You can record it casually, which just fills the gap of the recent blog)

Because it's just a tool for your convenience, you don't need any graphical interface. Just write it in Java. Let's see the effect picture first~

Hey, it's a good thing to suddenly find that you can write programs. If you download more than 1000 facial expression pictures manually and change their names, you have to be busy for 2 days and 2 nights..

Well, to get back to business, let's talk about the code implementation, which is divided into three steps:

1. Get JSON data

2. Download according to the picture resource address provided by Jason data

3. Classification, standard naming

Let's first look at the JSON data format:

For ease of operation, I encapsulated a data entity class

Then I wrote a tool class to encapsulate some methods

Used for processing (acquisition of network data, deserialization of JSON data, download of image resources)

For the processing of JSON data in the above code, I use the gson tool class provided by Google

For those who don't know how to use the gson class, you can read an article I wrote before:

《@L_419_0@》: http://www.cnblogs.com/lichenwei/p/3987429.html

Next, call the main class:

It's over here. If you have any unclear friends, you can comment and exchange in the following article.

Author: Balla_ Rabbit origin: http://www.cnblogs.com/lichenwei/ The copyright of this article belongs to the author and the blog park. Reprint is welcome, but this statement must be retained without the consent of the author, and the original link must be given in an obvious position on the article page. I'm reading the children's shoes on my blog. I think you have extraordinary bearing. There's a king's spirit in your conversation. You must do something in the future! Next to the word "recommendation", you can easily point it. It's accurate. I won't accept a penny; If you're not sure, you can come back to me!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>