如何获得网页里的连接地址,网页里的代码是用PHP保存到本地了的,现在要做的事就是从保存的TXT文件里读取<a>xxxxx</a>
代码片段如下:
</tr><tr style="background: #eee;" ><td>2.3.1</td> <td align='center'><a href='http://wordpress.org/wordpress-2.3.1.zip'>zip</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.1.tar.gz'>tar.gz</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.1.md5'>md5</a></td>
</tr><tr ><td>2.3.2</td> <td align='center'><a href='http://wordpress.org/wordpress-2.3.2.zip'>zip</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.2.tar.gz'>tar.gz</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.2.md5'>md5</a></td>
</tr><tr style="background: #eee;" ><td>2.3.3</td> <td align='center'><a href='http://wordpress.org/wordpress-2.3.3.zip'>zip</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.3.tar.gz'>tar.gz</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.3.md5'>md5</a></td>
</tr></table>
代码片段如下:
</tr><tr style="background: #eee;" ><td>2.3.1</td> <td align='center'><a href='http://wordpress.org/wordpress-2.3.1.zip'>zip</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.1.tar.gz'>tar.gz</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.1.md5'>md5</a></td>
</tr><tr ><td>2.3.2</td> <td align='center'><a href='http://wordpress.org/wordpress-2.3.2.zip'>zip</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.2.tar.gz'>tar.gz</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.2.md5'>md5</a></td>
</tr><tr style="background: #eee;" ><td>2.3.3</td> <td align='center'><a href='http://wordpress.org/wordpress-2.3.3.zip'>zip</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.3.tar.gz'>tar.gz</a></td>
<td align='center'><a href='http://wordpress.org/wordpress-2.3.3.md5'>md5</a></td>
</tr></table>
$content = file($file_name);
foreach($content as $line)
{
}这样读每一行数据,然后strpos找到href
再从href后找到两个单引号之间的就是链接...
具体代码不写了,就是个字符串操作
foreach($matches as $match)
echo "Link: ".$match[1]."\tText: ".trim($match[2])."<br/>";