品牌logo

main
anna1795 2 years ago
parent 0af1f19ae2
commit 5188bab2af

@ -27,6 +27,19 @@
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>

@ -20,4 +20,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1701761340333</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

@ -1,9 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,85 @@
package cj.reptile;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Brand {
public static String urlName(String filename) {
filename = filename.replaceAll(":", "");
filename = filename.replaceAll("\\*", "");
filename = filename.replaceAll("\\?", "");
filename = filename.replaceAll("<", "");
filename = filename.replaceAll(">", "");
filename = filename.replaceAll("|", "");
return filename;
}
public static void download(String urlString, String savePath, String filename) throws IOException {
// System.out.println(urlString);
// System.out.println(savePath+filename);
// 构造URL
URL url = new URL(urlString);
// 打开连接
URLConnection con = url.openConnection();
// 设置请求超时为20s
con.setConnectTimeout(200 * 1000);
// 文件路径不存在 则创建
File sf = new File(savePath);
if (!sf.exists()) {
sf.mkdirs();
}
InputStream in = con.getInputStream();
OutputStream out = new FileOutputStream(sf.getPath() + "\\" + filename);
// 创建缓冲区
byte[] buff = new byte[1024];
int n;
// 开始读取
while ((n = in.read(buff)) >= 0) {
out.write(buff, 0, n);
}
}
public static void main(String[] args) throws IOException {
String letter = "";
for (int a = 0; a < 26; a++) {
char chr = (char) ((int) 'A' + a);
letter = chr + "";
Connection connect = Jsoup.connect("https://www.autohome.com.cn/grade/carhtml/" + letter + ".html");
Document document = connect.get();
Elements els = document.select("dl");
for (int i = 0; i < els.size(); i++) {
Element e = els.get(i);
String src = e.select("dt a img").attr("src");
String imgurl = "https:" + src;
System.out.println(imgurl);
String pai = e.select("dt div a").text();
String path = "D:\\blogo\\" + pai;
File folder = new File(imgurl);
String name = pai;
Long id = (long) name.hashCode();
id += Integer.MAX_VALUE;
String newName = id+".png";
folder.mkdirs();
download(imgurl,path,newName);
}
}
}
}

@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Wed Nov 29 14:44:11 CST 2023
#Tue Jan 02 16:45:53 CST 2024
m2e.projectLocation=D\:\\code\\reptile
m2e.projectName=cj-reptile
groupId=cj

Loading…
Cancel
Save