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

Wrong Selection? #197

Open
jeromekwek opened this issue Jul 29, 2015 · 3 comments
Open

Wrong Selection? #197

jeromekwek opened this issue Jul 29, 2015 · 3 comments

Comments

@jeromekwek
Copy link

Hi,

I'm trying to use CsQuery to go through some pages of Thesaurus.com

Using the address http://www.thesaurus.com/browse/test as an example, the code I'm using is as follows:

CQ document = CQ.CreateFromUrl("http://www.thesaurus.com/browse/test");
                var selectionHtml = document.Select("#filters-0 > div.relevancy-block > div > ul:nth-child(1) > li:nth-child(1) > a");

Result from CsQuery:

{<a class="common-word" href="http://www.thesaurus.com/browse/search" data-id="1" data-category='{"name": "relevant-3", "color": "#fcbb45"}' data-complexity="1" data-length="1">...</a>}

Result from jQuery:

<a href="http://www.thesaurus.com/browse/analysis" class="common-word" data-id="5" data-category="{&quot;name&quot;: &quot;relevant-3&quot;, &quot;color&quot;: &quot;#fcbb45&quot;}" data-complexity="1" data-length="2" style="font-weight: 400; color: rgb(51, 51, 51); background-color: rgb(252, 187, 69);">
<span class="text">analysis</span>
<span class="star inactive">star</span>
</a>

Both are using the same dom selection (i.e. #filters-0 > div.relevancy-block > div > ul:nth-child(1) > li:nth-child(1) > a), but CsQuery is returning me "search" while jQuery is returning me "analysis", which is correct. Any idea what's going on?

@BenJury
Copy link

BenJury commented Jul 29, 2015

The HTML isn’t the same.

In your browser there is some JS running post fetch which changes the order, this won’t happen in CQ.

If you slow your browser down you can see it happen. (Grab attached.)

@jeromekwek
Copy link
Author

Thanks for your quick reply, Ben!

In that case, is there any way for CsQuery to "wait" for the page to process completely (with the new order), and then return with the actual result as displayed?

Or are there any other workaround/s for this issue?

@BenJury
Copy link

BenJury commented Jul 29, 2015

It doesn’t run javascript, so no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants