Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何提取特定的url';来自<;a href标签?_Java_Html_Matcher - Fatal编程技术网

Java 如何提取特定的url';来自<;a href标签?

Java 如何提取特定的url';来自<;a href标签?,java,html,matcher,Java,Html,Matcher,我试图从html标记中提取特定数据。我想提取imgurl和surl。以下是HTML代码: <a href="/images/search?q=nba&amp;view=detailv2&amp;&amp;&amp; id=FE19E7BB2916CE8B6CD78148F3BC0656D151049A&amp; selectedIndex=3&amp; ccid=2%2f7OBkGc&amp; simid=60803568173462

我试图从html
标记中提取特定数据。我想提取
imgurl
surl
。以下是HTML代码:

<a href="/images/search?q=nba&amp;view=detailv2&amp;&amp;&amp;
id=FE19E7BB2916CE8B6CD78148F3BC0656D151049A&amp;
selectedIndex=3&amp;
ccid=2%2f7OBkGc&amp;
simid=608035681734625885&amp;
thid=JN.tdPCsRj4HyJzbwA%2bgXsS8g" 
ihk="JN.tdPCsRj4HyJzbwA+gXsS8g" 
m="{ns:&quot;images&quot;,k:&quot;5070&quot;,dirovr:&quot;ltr&quot;,
mid:&quot;FE19E7BB2916CE8B6CD78148F3BC0656D151049A&quot;,
surl:&quot;http://www.nba.com/gallery/rookie/070727_1.html&quot;,
imgurl:&quot;http://www.nba.com/media/draft_class_3_07_070727.jpg
&quot;,
ow:&quot;300&quot;,docid:&quot;608035681734625885&quot;,oh:&quot;192&quot;,tft:&quot;58&quot;}" 
mid="FE19E7BB2916CE8B6CD78148F3BC0656D151049A" 
t1="The 2007 NBA Draft Class" 
t2="625 x 400 · 374 kB · jpeg" 
t3="www.nba.com/gallery/rookie/070727_1.html" 
h="ID=images,5070.1"><img data-bm="16" 
src="https://tse3.mm.bing.net/th?id=JN.tdPCsRj4HyJzbwA%2bgXsS8g&amp;w=217&amp;h=142&amp;c=7&amp;rs=1&amp;qlt=90&amp;o=4&amp;pid=1.1" 
style="width:217px;height:142px;" width="217" height="142">
</a>

请帮帮我!我希望你能理解我的问题。正在等待答案。

-您检查过这个吗?将
if(m.find())
更改为
while(m.find())
。谢谢!!!但是我编辑了我的问题请看一看
String title = "dog";

        String url =    "https://www.bing.com/images/search?q="+title+"&FORM=HDRSC2";


        try {
            Document doc = Jsoup.connect(url).get();
            Elements img = doc.getElementsByTag("a");


            for (Element el : img) {
                String src = el.absUrl("imgurl");

                System.out.println(src);

            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }