Reputation: 31
I am very new to this web crawling. I am using crawler4j to crawl the websites. I am collecting the required information by crawling these sites. My problem here is I was unable to crawl the content. Because result of crawling is JavaScript code. But i can get DOM HTML on web browser' inspect. How can i get actual DOM HTML by using java.
Here is getting DOM by using Jsoup or Crawler4j.
<!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>
i expected that result;
<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>
Upvotes: 0
Views: 555
Reputation: 5751
As described in the related #49 or #197 on the project page of crawler4j
, Javascript execution / rendering of content using ajax / javascript is not possible with crawler4j
at the moment as it does not include a javascript engine for that purpose.
However, you could by-pass this behaviour by adding a combination of Selenium and/or CasperJS and/or PhantomJS in front of crawler4j
.
Upvotes: 1