我对此网络爬虫非常陌生。我正在使用crawler4j来爬网网站。我正在通过爬网这些网站来收集所需的信息。我的问题是我无法抓取内容。因为爬网的结果是JavaScript代码。但是我可以在Web浏览器的检查中获得DOM HTML。如何使用Java获取实际的DOM HTML。
这里是通过使用Jsoup或Crawler4j获取DOM。
<!doctype html>
<html class="no-js" lang="en">
<head>
<title>title</title>
</head>
<body class="component mouse-active body--navigation-fixed" data-js="_mouseActive, _fixed, _component">
<script type="text/javascript">
var utag_data = {
page_name: "personel:rootpage", // Page name
channel: "personel:rootpage2", // s.channel (Section)
page_type: "personel:rootpage2", // s.channel (Section)
login_status: "not-logged-in", // s.channel (Section)
}
</script>
<script type="text/javascript">
some javascript code
</script>
<form id="postForm" action="https://testurl.com/index.php" method="post">
</form>
<script type="text/javascript">
some javascript code
</script>
</body>
</html>
我希望得到这个结果;
<html lang="tr" class="gccc_com_tr">
<head>
</head>
<body class="page--home" data-gr-c-s-loaded="true">
<div class="header">
<div class="nav-top">
<div class="container">
<ul class="menu menu-left">
<li class="active"> <a href="https://www.vodafone.com.tr/" accesskey="B">Bireysel</a> </li>
<li> <a href="https://www.vodafone.com.tr/VodafoneBusiness/index.php" accesskey="K">Kurumsal</a> </li>
<li> <a href="https://www.vodafone.com.tr/en/roam-with-vodafone.php">Visiting Turkey</a> </li>
</ul>
<ul class="menu menu-right">
<li> <a href="http://www.vodafone.com.tr/auto-login.php?pageId=InvoicePayment&paymentFlag=true" accesskey="A">Fatura Öde</a> </li>
<li> <a href="http://www.vodafone.com.tr/auto-login.php?pageId=TopupPayment&paymentFlag=true" accesskey="L">TL Yükle</a> </li>
</ul>
</div>
</div>
<nav class="navbar">
<div class="container">
<div id="navbar">
<div class="nav navbar-logo" itemscope="" itemtype="https://schema.org/Organization">
<a href="/" class="logo" itemprop="url">
<span class="icon-vodafone">
<span class="path1"></span>
</span>
<span style="display: none;">
Vodafone
</span>
</a>
</div>
<ul class="nav navbar-nav list-nav-main">
<div class="">
<li class="hide--lg hide--md"></li>
</div>
</ul>
</ul>
</div>
</div>
</nav>
</div>
<footer class="row">
<div class="container top">
</div>
</footer>
<script type="text/javascript" src="/assets/v2/js/script.build.app.js" defer="" async=""></script>
</body>
</html>