我有以下html:
<!-- other html -->
<div class="my_class_name_1" style="padding-bottom: 125%;"><img alt="lorem ipsum dolor sit" class="my_class_name_2" decoding="auto" sizes="111px" srcset="https:/link1.jpg def1,https:/link2.jpg def2,https:/link1.jpg def3" src="https:/link3.jpg" style=""></div>
<!-- other html -->
从这里开始,我只想从src https:/link3.jpg
中获取链接,但无法获得任何帮助。
在整个html文档中,只有一次<div class="my_class_name_1"
答案 0 :(得分:0)
<Connector
protocol="org.apache.coyote.http11.Http11AprProtocol"
port="8443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
SSLCertificateFile="/usr/local/ssl/server.crt"
SSLCertificateKeyFile="/usr/local/ssl/server.pem"
SSLVerifyClient="optional" SSLProtocol="TLSv1+TLSv1.1+TLSv1.2"/>
输出:
Document doc = Jsoup.parse("<div class=\"my_class_name_1\" style=\"padding-bottom: 125%;\"><img alt=\"lorem ipsum dolor sit\" class=\"my_class_name_2\" decoding=\"auto\" sizes=\"111px\" srcset=\"https:/link1.jpg def1,https:/link2.jpg def2,https:/link1.jpg def3\" src=\"https:/link3.jpg\" style=\"\"></div>");
System.out.println(doc.select(".my_class_name_1 img").first().attr("src"));