2
String str = " <iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/UMUeWqnwmjs\" frameborder=\"0\" allowfullscreen></iframe>";
如何從此標記獲取Src?如何使用java從<iframe>獲取src/url
String str = " <iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/UMUeWqnwmjs\" frameborder=\"0\" allowfullscreen></iframe>";
如何從此標記獲取Src?如何使用java從<iframe>獲取src/url
在這種簡單的情況下,你可以使用regexp(通常你不應該用它來解析html)。下面的代碼將查找src和檢索:
Matcher matcher = Pattern.compile("src=\"([^\"]+)\"").matcher(str);
matcher.find();
String src = matcher.group(1);
src
將包含IFRAME你的src。
#krzyk謝謝你。<3它的工作... – AMU