Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No results returned from some React websites #50

Open
opsdemon opened this issue Jun 20, 2019 · 1 comment
Open

No results returned from some React websites #50

opsdemon opened this issue Jun 20, 2019 · 1 comment
Labels
js-engine Issues related to the js engine

Comments

@opsdemon
Copy link

opsdemon commented Jun 20, 2019

Hi,

I've been using HtmlUnit for the last few weeks and it really is a great tool - very flexible with a nice intuitive API.

In the last few days I've encountered issues trying to scrape the following 2 websites:
https://www.elastic.co/blog/
https://blog.bitrise.io/

Htmlunit: 2.35.0

Both sites seem to be using React which I suspect is related to the problem.

Here is the code to reproduce the issue:

	WebClient client = new WebClient();
	client.setJavaScriptTimeout(30000);
	client.getOptions().setTimeout(60000);
	client.getOptions().setRedirectEnabled(true);
	client.getOptions().setThrowExceptionOnFailingStatusCode(false);
	client.getOptions().setThrowExceptionOnScriptError(false);
	client.getOptions().setCssEnabled(false);
	client.getOptions().setJavaScriptEnabled(true);
	client.getOptions().setPrintContentOnFailingStatusCode(false);
	client.getCookieManager().setCookiesEnabled(false);
	client.getOptions().setUseInsecureSSL(true);
	client.getCurrentWindow().setInnerHeight(60000);
	client.setAjaxController(new NicelyResynchronizingAjaxController());

	// Example 1
	String url = "https://www.elastic.co/blog/";
	String selector = ".main-wrapper .blog-column";

	// Example 2
	//String url = "https://blog.bitrise.io/";
	//String selector = ".articles .article-container";

	HtmlPage page = client.getPage(url);
	client.waitForBackgroundJavaScript(30000);

	DomNodeList<DomNode> results = page.querySelectorAll(selector);
	System.out.println("Found "+results.size()+" results");

Both examples always produce zero results even though if you click "Inspect" on the pages the CSS classes are all present.

I've tried changing the client options based on what I've read from previous issues but none of the changes made any difference.

I'd really appreciate some pointers as I've spent hours trying to crawl these pages but couldn't make it work.

Thanks,

Gerald.

@rbri rbri added the js-engine Issues related to the js engine label Mar 27, 2024
@rbri
Copy link
Member

rbri commented Mar 27, 2024

see #755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js-engine Issues related to the js engine
Projects
None yet
Development

No branches or pull requests

2 participants