我想从下面的html代码得到softwareVersion
。Matcher.find()返回false的android
<div class="title">Current Version</div> <div class="content" itemprop="softwareVersion"> 1.1.3 </div> </div> <div class="meta-info"> <div class="title">Requires Android</div> <div class="content" itemprop="operatingSystems"> 2.2 and up </div> </div>
我用下面的代码为
String Html = GetHtml("https://play.google.com/store/apps/details?id="+ AppID)
Pattern pattern = Pattern.compile("softwareVersion\">[^<]*</dd");
Matcher matcher = pattern.matcher(Html);
matcher.find();
String GetHtml(String url1)
{
String str = "";
try
{
URL url = new URL(url1);
URLConnection spoof = url.openConnection();
spoof.setRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)");
BufferedReader in = new BufferedReader(new InputStreamReader(
spoof.getInputStream()));
String strLine = "";
// Loop through every line in the source
while ((strLine = in.readLine()) != null)
{
str = str + strLine;
}
}
catch (Exception e)
{
}
return str;
}
但匹配总是返回false。我认为我有问题模式任何人都可以请求帮助我 谢谢
使用HTML解析器如[JSoup](http://jsoup.org/) – Reimeus
怎么样?我不知道。下面的代码有模式问题,我不太了解模式。 – user2582308
使用上面的链接阅读。 – Reimeus