我想以字符串的形式从https://www.java.com/de/download/manual.jsp获取脱机安装程序x86和x64的下载url。我该怎么做呢?
我可以用file_get_contents();得到这个页面
$page = file_get_contents('https://www.java.com/de/download/manual.jsp');
我需要哪些函数来处理字符串?
我需要这部分源代码:
<a title="Download der Java-Software für Windows Offline" href="http://javadl.sun.com/webapps/download/AutoDL?BundleId=113217">
Windows Offline</a>和
<a title="Download der Java-Software für Windows (64-Bit)" href="http://javadl.sun.com/webapps/download/AutoDL?BundleId=113219">
Windows Offline (64-Bit)</a>问题是,在版本发布后,url可能会发生变化。
发布于 2015-11-29 00:56:56
$page = file_get_contents('https://www.java.com/de/download/manual.jsp');
preg_match("'<a title=\"Download der Java-Software für Windows Offline\" href=\"(.*?)\">(.*?)</a>'si", $page, $match);
preg_match("'<a title=\"Download der Java-Software für Windows \(64-Bit\)\" href=\"(.*?)\">(.*?)</a>'si", $page, $match1);
$d_x86 = $match[0];
$d_x64 = $match1[0];
preg_match("'http*://\w+.\w+.\w+/\w+/\w+/\w+.\w+=\d+'", $d_x86, $match3);
preg_match("'http*://\w+.\w+.\w+/\w+/\w+/\w+.\w+=\d+'", $d_x64, $match4);
$d_x86_url = $match3[0];
$d_x64_url = $match4[0];
echo "<a href=\"$d_x86_url\">Download aktuellste JRE für Windows x86</a><br>";
echo "<a href=\"$d_x64_url\">Download aktuellste JRE für Windows x64</a>";https://stackoverflow.com/questions/33947489
复制相似问题