简体   繁体   English

从使用JavaScript即时生成文本的网页中以Java解析文本

[英]Parsing Text in Java from a Webpage that uses JavaScript to Generate the Text on-the-fly

I like playing Magic: The Gathering, and I also have a database of my collection. 我喜欢玩魔术:聚会,而且我也有一个收藏数据库。 Magic set information was easy to obtain, since I could parse it directly from the HTML URL stream I opened, but I'm now trying to obtain prices for the cards as well from Star City Games (a MTG vendor). 魔术套信息很容易获得,因为我可以直接从打开的HTML URL流中解析出魔术套信息,但是我现在正试图从Star City Games(MTG供应商)那里获得这些牌的价格。 However, when I view source, there are no prices in the HTML; 但是,当我查看源代码时,HTML中没有价格。 it's all done through JavaScript on-the-fly. 所有这些都是通过JavaScript即时完成的。 Here's an example page for reference: http://sales.starcitygames.com/search.php?substring=Snapcaster+Mage&t_all=All&start_date=2010-01-29&end_date=2012-04-22&order_1=finish&limit=25&action=Show%2BDecks&card_qty%5B1%5D=1&auto=Y 这是供参考的示例页面: http : //sales.starcitygames.com/search.php?substring=Snapcaster+Mage&t_all=All&start_date=2010-01-29&end_date=2012-04-22&order_1=finish&limit=25&action=Show%2BDecks&card_qty%5B1 %5D = 1&auto = Y

The webpage generates the following HTML: http://pastebin.com/Psrpri8r . 该网页生成以下HTML: http : //pastebin.com/Psrpri8r I just want to be able to read the text "24.99." 我只希望能够阅读文本“ 24.99”。 All of the code I'm using is in Java. 我正在使用的所有代码都在Java中。

Thanks. 谢谢。

You need to run javascript... Try selenium . 您需要运行javascript ...尝试selenium

If you dont want to learn him, i've an Hacky solution (Warning: very complicated): Download the page to your computer (Download also all the .JS pages), Edit the JS code that send the relevant data to your server instead showing it, And open this page in browser . 如果您不想学习他,我有一个Hacky解决方案(警告:非常复杂):将页面下载到计算机上(还下载所有.JS页面),编辑将相关数据发送到服务器的JS代码显示它,然后在浏览器中打开此页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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