显示网站的完整HTML代码

时间:2016-03-23 19:52:01

标签: html parsing url jsoup

我正在尝试解析特定内容的HTML代码,但我遇到的问题是某些网站要求您点击“显示更多”按钮。

当我抓取URL时,无法告诉它我想要点击“显示更多”按钮的完整代码。有没有办法获取页面的完整源代码,因为它在一个点之后不断被切断。

示例网站:https://play.google.com/store/search?q=fm%20radio&c=apps&hl=en

源代码在“Radio hungary”应用程序中被截断,该应用程序是自动加载的最后一个应用程序。

当我加载所有内容然后尝试查看页面源代码时,甚至会发生这种情况。

结束于:

style="display:none"> Show More </button> <div class="bottom-loading" style="display:none"></div> <div class="footer"> <div class="footer-links-container"> <span class="copyright"> ©2016 Google</span> <a class="footer-link id-no-nav" href="https://play.google.com/intl/en_us/about/play-terms.html" target="_blank"> Site Terms of Service</a> <a class="footer-link id-no-nav" href="http://www.google.com/intl/en_us/policies/privacy/" target="_blank"> Privacy Policy</a>  <a class="footer-link id-no-nav" href="http://developer.android.com/index.html" target="_blank"> Developers</a> <a class="footer-link id-no-nav" href="https://play.google.com/artists" target="_blank"> Artists</a>  <a class="footer-link id-no-nav" href="https://support.google.com/googleplay/?p=about_play" target="_blank"> About Google</a>   </div>  </div> </div></div><div class="loading" jscontroller="EgJAl" jsaction="rcuQ6b:rcuQ6b" id="page-load-indicator"></div><div id="instrument-manager-parent"></div><script src="https://wallet.google.com/inapp/lib/buy.js"></script><script 

即使我点击了显示更多按钮。 这样做的目的是获取图像的所有URL,我不能手工完成这个,因为我们有成千上万的图像。

2 个答案:

答案 0 :(得分:0)

我相信如果您只是利用Javascript HTML DOM方法,您就可以实现您想要实现的目标。

这会有所帮助:http://www.w3schools.com/js/js_htmldom_methods.asp

通过使用它,您可以定位特定的元素/ ID /类,并提取或修改所需的信息。 Jquery也将为您提供很多帮助。

答案 1 :(得分:0)

你可以使用Javascript dom解决它,步骤

  • 将您的内容保存在div元素中
  • 将其默认高度设置为固定值
  • 点击show more链接执行javascript函数,使div元素高度为auto

通过这种方式,您可以使用javascript

显示内容摘录

如果你去服务器端,你可以创建一个新页面来显示内容。

相关问题