<span class="price final-price our fksk-our" id="fk-mprod-our-id">
Rs.
<span class="small-font"> </span>
315
</span>
, HTML Price tag.
I suggest you use jSoup. Download here
Now, using this library, parsing is easier, all you need to do.
Document doc = null;
try{
doc = Jsoup.connect("You page URL comes here").get();
}catch(IOException e){
}
String priceHtml = doc.select("#fk-mprod-our-id").get(0).html().trim();
System.out.println("html fetched: "+priceHtml);
priceHtml = priceHtml.replace("((<span(.)*?>)(.)*(</span>))", "");
System.out.println("My Price tag: "+priceHtml);
I have not tested the code above, but it should work. It may contain a small error. but with a little effort you can make it work.
Parsingsometimes it takes time. You must do this in the background. When the background parsing is complete, send the data to the user interface stream.
Edit:
surrounds your call connectwith try catch.
and make sure you have the following permissions set to androidManifest.xml
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
source
share