使用Java从td href元素提取链接

使用Java从td href元素提取链接,java,html,velocity,Java,Html,Velocity,我有以下HTML代码: <table id="myTable"> <tr class="header"> <th> FLIGHT NUMBER </th> <th> AIRLINE </th> <th> FROM AIRPORT </th> <th> TO AIRPORT <

我有以下HTML代码:

<table id="myTable">
    <tr class="header">
        <th> FLIGHT NUMBER </th>
        <th> AIRLINE </th>
        <th> FROM AIRPORT </th>
        <th> TO AIRPORT </th>
        <th> FLIGHT DATE </th>
        <th> DEPARTURE TIME </th>
        <th> ARRIVING TIME </th>
        <th> BOOK </th>
    </tr>
    #foreach ($flight in $flights)
        <tr>
            <td>$flight.flightNumber</td>
            <td>$flight.airline</td>
            <td>$flight.fromAirportName</td>
            <td>$flight.toAirportName</td>
            <td>$flight.flightDate</td>
            <td>$flight.departureTime</td>
            <td>$flight.arrivingTime</td>
            <td class="topic"><a href="/booking/${flight.flightNumber}">
                <p style="text-align:center">BOOK</p></a></td>
        </tr>
    #end
</table>

航班号
航空公司
从机场
到机场
航班日期
出发时间
到达时间
书
#foreach($航班中的航班)
$flight.flightNumber
$flight.airline
$flight.fromAirportName
$flight.toAirportName
$flight.flightDate
$flight.出发时间
$flight.arrivingTime
#结束
我想使用Java从
中提取
flight.flightNumber

我尝试了
元素
,但不知道它是如何工作的。

您可以使用Rejex查找$flight.flightNumber。代码如下所示:

Pattern pattern = Pattern.compile("<tr>\\s*<td>([^<]+)<\\/td>");
Matcher matcher = pattern.matcher(command);

Pattern=Pattern.compile(“\\s*”([^Show)显示您的工作。