1. 程式人生 > >【圖片】批量獲取幾百張圖片

【圖片】批量獲取幾百張圖片

null beans div ole 性感 cde 感覺 final 尺度

用途:需要圖片時我們經常是去百度裏隨便找幾張,次數多了就有點煩了,這個工具類就是批量獲取幾百張圖片的url和描述。
  1. public class PicUrls {
  2. public static ArrayList<BasicPicBean> getPicList() {
  3. ArrayList<UrlBean> beans = new ArrayList<>();
  4. beans.addAll(Arrays.asList(beans0));
  5. beans.addAll(Arrays.asList(beans1));
  6. beans.addAll(Arrays.asList
    (beans2));
  7. beans.addAll(Arrays.asList(beans3));
  8. ArrayList<BasicPicBean> urlList = new ArrayList<>();
  9. for (UrlBean bean : beans) {
  10. urlList.addAll(getPicList(bean));
  11. }
  12. return urlList;
  13. }
  14. private static ArrayList<BasicPicBean> getPicList(UrlBean bean) {
  15. ArrayList<BasicPicBean
    > picList = new ArrayList<>();
  16. for (int i = 0; i < bean.picCount; i++) {
  17. String picIndex = "" + (bean.picIndexFrom + i);
  18. if (bean.isWith0 && bean.picIndexFrom + i <= 9) picIndex = "0" + picIndex;
  19. String picUrl = bean.host + bean.urlHeader + picIndex + bean.urlEnder;//例如.../1.jpg
  20. if (bean.picWidth > 0) picUrl = picUrl + "!" + bean.picWidth + bean.urlEnder;//例如.../1.jpg!960.jpg
  21. picList.add(new BasicPicBean(bean.picDes, picUrl));
  22. }
  23. return picList;
  24. }
  25. //******************************************************************************************
  26. private static final String HOST0 = "http://img1.mm131.com/pic/";//網站【http://www.mm131.com/】
  27. private static final String HOST1 = "http://img.mmjpg.com/";//網站【http://www.mmjpg.com/】
  28. private static final String HOST2 = "http://pic.meituba.com/uploads/allimg/";//網站【】
  29. private static final String HOST3 = "http://pic2116.ytqmx.com:82/";//網站【http://www.5442.com/】
  30. private static final UrlBean[] beans0 = {
  31. //http://img1.mm131.com/pic/2016/1.jpg
  32. new UrlBean.Builder().host(HOST0).urlHeader("996/").picIndexFrom(1).picCount(9).picDes("北影校花余雨高清寫真圖片").build(),
  33. new UrlBean.Builder().host(HOST0).urlHeader("2958/").picIndexFrom(2).picCount(23).picDes("童顏嫩妹桃子黑絲大尺度誘惑").build(),
  34. new UrlBean.Builder().host(HOST0).urlHeader("2939/").picCount(23).picDes("清純少女劉奕寧酥胸覆白色內衣").build(),
  35. new UrlBean.Builder().host(HOST0).urlHeader("2343/").picCount(23).picDes("萌妹銷魂寫真身材惹火讓人欲罷不能").build(),
  36. new UrlBean.Builder().host(HOST0).urlHeader("2935/").picCount(23).picDes("性感女神楊晨晨透視睡衣大膽秀乳").build(),
  37. };
  38. private static final UrlBean[] beans1 = {
  39. //http://img.mmjpg.com/2015/210/1.jpg
  40. new UrlBean.Builder().host(HOST1).urlHeader("2015/444/").picCount(31).picDes("模範學院美少女柳侑綺制服大片").build(),
  41. new UrlBean.Builder().host(HOST1).urlHeader("2015/74/").picCount(38).picDes("極品女神可兒私拍秀完美身材").build(),
  42. new UrlBean.Builder().host(HOST1).urlHeader("2017/990/").picCount(47).picDes("香艷妹子雪白的美胸絕對讓你大飽眼福").build(),
  43. new UrlBean.Builder().host(HOST1).urlHeader("2017/962/").picCount(37).picDes("真誘人啊!女神雪白的美胸看著很有感覺").build(),
  44. new UrlBean.Builder().host(HOST1).urlHeader("2017/936/").picCount(37).picDes("身材嬌美純天然美女小葉子美胸藝術照").build(),
  45. };
  46. private static final UrlBean[] beans2 = {
  47. //http://pic.meituba.com/uploads/allimg/2016/07/30/43_485.jpg
  48. new UrlBean.Builder().host(HOST2).urlHeader("2015/10/23/2").picIndexFrom(47).picCount(12).picDes("呆萌可愛的哆啦A夢動漫").build(),
  49. new UrlBean.Builder().host(HOST2).urlHeader("2016/05/26/43_3").picIndexFrom(68).picCount(6).picDes("熱血動漫龍珠帥氣動漫").build(),
  50. new UrlBean.Builder().host(HOST2).urlHeader("2016/03/25/43_205").picIndexFrom(74).picCount(5).picDes("海賊王紅發香克斯動漫").build(),
  51. new UrlBean.Builder().host(HOST2).urlHeader("2016/09/08/43_4").picIndexFrom(76).picCount(12).picDes("可愛快樂的女孩動漫").build(),
  52. new UrlBean.Builder().host(HOST2).urlHeader("2016/07/30/43_4").picIndexFrom(85).picCount(12).picDes("精選超萌小貓咪").build(),
  53. };
  54. private static final UrlBean[] beans3 = {
  55. //http://pic2116.ytqmx.com:82/2017/0531/21/1.jpg!960.jpg
  56. new UrlBean.Builder().host(HOST3).urlHeader("2017/0531/21/").picCount(9).picWidth(960).picDes("德國美景風景壁紙").build(),
  57. new UrlBean.Builder().host(HOST3).urlHeader("2017/0531/21/").picCount(9).picDes("德國美景風景壁紙").build(),//加載對應原圖
  58. new UrlBean.Builder().host(HOST3).urlHeader("2016/0829/38/").picCount(15).picWidth(960).picDes("宋茜清純桌面壁紙").build(),
  59. new UrlBean.Builder().host(HOST3).urlHeader("2017/0531/9/").picCount(4).picDes("王麗坤優雅亮相 被贊坐姿教科書").build(),
  60. new UrlBean.Builder().host(HOST3).urlHeader("2017/0602/38/").picCount(10).picDes("性感爆乳美女戶外美照").build(),
  61. };
  62. //******************************************************************************************
  63. static class UrlBean {
  64. public String picDes;//圖片描述
  65. public String host;//存放圖片的主機地址
  66. public String urlHeader;
  67. public String urlEnder;//默認為= ".jpg"
  68. public int picCount;//此系列圖片的數量。所有圖片都是以數字命名的,比如1.jpg、2.jpg
  69. public int picIndexFrom;//此系列圖片開始的序號位置,默認為1
  70. public int picWidth;//圖片寬度
  71. public boolean isWith0;//如,當為01.jpg時是否包含前面的0。默認不包含
  72. private UrlBean(Builder builder) {
  73. picDes = builder.picDes;
  74. host = builder.host;
  75. urlHeader = builder.urlHeader;
  76. urlEnder = builder.urlEnder;
  77. picCount = builder.picCount;
  78. picIndexFrom = builder.picIndexFrom;
  79. picWidth = builder.picWidth;
  80. isWith0 = builder.isWith0;
  81. }
  82. static final class Builder {
  83. private String picDes = "包青天作品";
  84. private String host = "";
  85. private String urlHeader = "";
  86. private String urlEnder = ".jpg";//默認為".jpg"
  87. private int picCount = 1;
  88. private int picIndexFrom = 1;
  89. private int picWidth = 0;
  90. private boolean isWith0 = false;
  91. public Builder() {
  92. }
  93. public Builder urlHeader(String val) {
  94. urlHeader = val;
  95. return this;
  96. }
  97. public Builder urlEnder(String val) {
  98. urlEnder = val;
  99. return this;
  100. }
  101. public Builder picCount(int val) {
  102. picCount = val;
  103. return this;
  104. }
  105. public Builder picIndexFrom(int val) {
  106. picIndexFrom = val;
  107. return this;
  108. }
  109. public Builder picWidth(int val) {
  110. picWidth = val;
  111. return this;
  112. }
  113. public Builder isWith0(boolean val) {
  114. isWith0 = val;
  115. return this;
  116. }
  117. public Builder host(String val) {
  118. host = val;
  119. return this;
  120. }
  121. public Builder picDes(String val) {
  122. picDes = val;
  123. return this;
  124. }
  125. public UrlBean build() {
  126. return new UrlBean(this);
  127. }
  128. }
  129. }
  130. //******************************************************************************************
  131. public static class BasicPicBean {
  132. public String name;
  133. public String url;
  134. public BasicPicBean(String name, String url) {
  135. this.name = name;
  136. this.url = url;
  137. }
  138. }
  139. }
2017-6-5

null

【圖片】批量獲取幾百張圖片