首页 > 代码库 > 【图片】批量获取几百张图片
【图片】批量获取几百张图片
用途:需要图片时我们经常是去百度里随便找几张,次数多了就有点烦了,这个工具类就是批量获取几百张图片的url和描述。
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;
}
}
}
2017-6-5
null
【图片】批量获取几百张图片
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。