I want parse one line from html site, but my code not working
MainActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
TextView textView = (TextView)findViewById(R.id.result);
Document doc = null;
try {
doc = Jsoup.connect("http://ru.todaysdate365.com/").get();
Elements divs = doc.select("div#dateShow");
for (Element div : divs)
textView.setText(div.text());
} catch (IOException e) {
e.printStackTrace();
}
}
I parse div with id "dateShow" from http://ru.todaysdate365.com/
Sorry bro Your date is loaded by JavaScript and Jsoup doesn't support js. Use htmlUnit . Your website response .Look there is no date
<div class="jumbotron" style="text-align: center; height: 314px; margin-left: 15px; margin-right: 15px;">
<div>
<p style="font-size: 14px; text-decoration: underline;"> Дата сегодня: </p>
<div id="dateShow">
</div>
<script type="text/javascript">
$(function() {
var tz = jstz.determine();
var timezone = tz.name();
$("#dateShow").load("/getdate.php?lang=ru&tz="+timezone);
});
</script>
</div>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.