【圖片】批量獲取幾百張圖片
阿新 • • 發佈:2017-06-06
null beans div ole 性感 cde 感覺 final 尺度 用途:需要圖片時我們經常是去百度裏隨便找幾張,次數多了就有點煩了,這個工具類就是批量獲取幾百張圖片的url和描述。
null
2017-6-5
public class PicUrls {
public static ArrayList<BasicPicBean> getPicList() {
ArrayList<UrlBean> beans = new ArrayList<>();
beans.addAll(Arrays.asList(beans0));
beans.addAll(Arrays.asList(beans1));
beans.addAll(Arrays.asList
(beans2));beans.addAll(Arrays.asList(beans3));
ArrayList<BasicPicBean> urlList = new ArrayList<>();
for (UrlBean bean : beans) {
urlList.addAll(getPicList(bean));
}
return urlList;
}
private static ArrayList<BasicPicBean> getPicList(UrlBean bean) {
ArrayList<BasicPicBean
> picList = new ArrayList<>();for (int i = 0; i < bean.picCount; i++) {
String picIndex = "" + (bean.picIndexFrom + i);
if (bean.isWith0 && bean.picIndexFrom + i <= 9) picIndex = "0" + picIndex;
String picUrl = bean.host + bean.urlHeader + picIndex + bean.urlEnder;//例如.../1.jpg
if (bean.picWidth > 0) picUrl = picUrl + "!" + bean.picWidth + bean.urlEnder;//例如.../1.jpg!960.jpg
picList.add(new BasicPicBean(bean.picDes, picUrl));
}
return picList;
}
//******************************************************************************************
private static final String HOST0 = "http://img1.mm131.com/pic/";//網站【http://www.mm131.com/】
private static final String HOST1 = "http://img.mmjpg.com/";//網站【http://www.mmjpg.com/】
private static final String HOST2 = "http://pic.meituba.com/uploads/allimg/";//網站【】
private static final String HOST3 = "http://pic2116.ytqmx.com:82/";//網站【http://www.5442.com/】
private static final UrlBean[] beans0 = {
//http://img1.mm131.com/pic/2016/1.jpg
new UrlBean.Builder().host(HOST0).urlHeader("996/").picIndexFrom(1).picCount(9).picDes("北影校花余雨高清寫真圖片").build(),
new UrlBean.Builder().host(HOST0).urlHeader("2958/").picIndexFrom(2).picCount(23).picDes("童顏嫩妹桃子黑絲大尺度誘惑").build(),
new UrlBean.Builder().host(HOST0).urlHeader("2939/").picCount(23).picDes("清純少女劉奕寧酥胸覆白色內衣").build(),
new UrlBean.Builder().host(HOST0).urlHeader("2343/").picCount(23).picDes("萌妹銷魂寫真身材惹火讓人欲罷不能").build(),
new UrlBean.Builder().host(HOST0).urlHeader("2935/").picCount(23).picDes("性感女神楊晨晨透視睡衣大膽秀乳").build(),
};
private static final UrlBean[] beans1 = {
//http://img.mmjpg.com/2015/210/1.jpg
new UrlBean.Builder().host(HOST1).urlHeader("2015/444/").picCount(31).picDes("模範學院美少女柳侑綺制服大片").build(),
new UrlBean.Builder().host(HOST1).urlHeader("2015/74/").picCount(38).picDes("極品女神可兒私拍秀完美身材").build(),
new UrlBean.Builder().host(HOST1).urlHeader("2017/990/").picCount(47).picDes("香艷妹子雪白的美胸絕對讓你大飽眼福").build(),
new UrlBean.Builder().host(HOST1).urlHeader("2017/962/").picCount(37).picDes("真誘人啊!女神雪白的美胸看著很有感覺").build(),
new UrlBean.Builder().host(HOST1).urlHeader("2017/936/").picCount(37).picDes("身材嬌美純天然美女小葉子美胸藝術照").build(),
};
private static final UrlBean[] beans2 = {
//http://pic.meituba.com/uploads/allimg/2016/07/30/43_485.jpg
new UrlBean.Builder().host(HOST2).urlHeader("2015/10/23/2").picIndexFrom(47).picCount(12).picDes("呆萌可愛的哆啦A夢動漫").build(),
new UrlBean.Builder().host(HOST2).urlHeader("2016/05/26/43_3").picIndexFrom(68).picCount(6).picDes("熱血動漫龍珠帥氣動漫").build(),
new UrlBean.Builder().host(HOST2).urlHeader("2016/03/25/43_205").picIndexFrom(74).picCount(5).picDes("海賊王紅發香克斯動漫").build(),
new UrlBean.Builder().host(HOST2).urlHeader("2016/09/08/43_4").picIndexFrom(76).picCount(12).picDes("可愛快樂的女孩動漫").build(),
new UrlBean.Builder().host(HOST2).urlHeader("2016/07/30/43_4").picIndexFrom(85).picCount(12).picDes("精選超萌小貓咪").build(),
};
private static final UrlBean[] beans3 = {
//http://pic2116.ytqmx.com:82/2017/0531/21/1.jpg!960.jpg
new UrlBean.Builder().host(HOST3).urlHeader("2017/0531/21/").picCount(9).picWidth(960).picDes("德國美景風景壁紙").build(),
new UrlBean.Builder().host(HOST3).urlHeader("2017/0531/21/").picCount(9).picDes("德國美景風景壁紙").build(),//加載對應原圖
new UrlBean.Builder().host(HOST3).urlHeader("2016/0829/38/").picCount(15).picWidth(960).picDes("宋茜清純桌面壁紙").build(),
new UrlBean.Builder().host(HOST3).urlHeader("2017/0531/9/").picCount(4).picDes("王麗坤優雅亮相 被贊坐姿教科書").build(),
new UrlBean.Builder().host(HOST3).urlHeader("2017/0602/38/").picCount(10).picDes("性感爆乳美女戶外美照").build(),
};
//******************************************************************************************
static class UrlBean {
public String picDes;//圖片描述
public String host;//存放圖片的主機地址
public String urlHeader;
public String urlEnder;//默認為= ".jpg"
public int picCount;//此系列圖片的數量。所有圖片都是以數字命名的,比如1.jpg、2.jpg
public int picIndexFrom;//此系列圖片開始的序號位置,默認為1
public int picWidth;//圖片寬度
public boolean isWith0;//如,當為01.jpg時是否包含前面的0。默認不包含
private UrlBean(Builder builder) {
picDes = builder.picDes;
host = builder.host;
urlHeader = builder.urlHeader;
urlEnder = builder.urlEnder;
picCount = builder.picCount;
picIndexFrom = builder.picIndexFrom;
picWidth = builder.picWidth;
isWith0 = builder.isWith0;
}
static final class Builder {
private String picDes = "包青天作品";
private String host = "";
private String urlHeader = "";
private String urlEnder = ".jpg";//默認為".jpg"
private int picCount = 1;
private int picIndexFrom = 1;
private int picWidth = 0;
private boolean isWith0 = false;
public Builder() {
}
public Builder urlHeader(String val) {
urlHeader = val;
return this;
}
public Builder urlEnder(String val) {
urlEnder = val;
return this;
}
public Builder picCount(int val) {
picCount = val;
return this;
}
public Builder picIndexFrom(int val) {
picIndexFrom = val;
return this;
}
public Builder picWidth(int val) {
picWidth = val;
return this;
}
public Builder isWith0(boolean val) {
isWith0 = val;
return this;
}
public Builder host(String val) {
host = val;
return this;
}
public Builder picDes(String val) {
picDes = val;
return this;
}
public UrlBean build() {
return new UrlBean(this);
}
}
}
//******************************************************************************************
public static class BasicPicBean {
public String name;
public String url;
public BasicPicBean(String name, String url) {
this.name = name;
this.url = url;
}
}
}
null
【圖片】批量獲取幾百張圖片