简体   繁体   中英

Getting “compiled” HTML-page using Jsoup

Page source code looks like this:

<td class="ftd">${row.time}</td>
<td class="mntd">${$item.getMTitle(row.movieId)}</td>
<td class="hntd" style="width:75px">${row.hall}</td>
<td class="ptd">${row.price}</td>
<td class="btd"><img class="butres" src="/image.png" alt=""/></td>

And the final code in the browser web-inspector looks like this:

<td class="ftd">Item1</td>
<td class="mntd">Item2</td>
<td class="hntd" style="width:75px">Item3</td>
<td class="ptd">Item4</td>
<td class="btd"><img class="butres" src="/image.png" alt=""></td>

I'm trying to parse web-page:

Document doc = Jsoup.connect("http://domain.com/").timeout(0).get();

But it gets only source code. How can I get a "compiled" code?

Thanks.

If you gave us the URL it'd be easier to help. jsoup doesn't execute JS (it's an HTML parser), which is why you're not seeing the data. My guess is that the data is coming in as json from an ajax request, using mustache.js as a template.

You can determine this by loading the page and looking at the network requests, using either your browser's network monitor, or a proxy like Charles . Then you can use jsoup or another tool to fetch the data URL and a json parser to parse it.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM