fimad / scalpel

A high level web scraping library for Haskell.
Apache License 2.0
323 stars 43 forks source link

// reverses the order of selection #54

Closed mitchellwrosen closed 7 years ago

mitchellwrosen commented 7 years ago

Hi, I discovered that calling something like...

htmls x

will match results in the opposite order as

htmls (x // y)

(assuming that there is one y inside each x).

Is this intended? Thanks!

fimad commented 7 years ago

That is not intentional, I would have expected the the same ordering.

fimad commented 7 years ago

I cannot seem to reproduce this:

ghci> let html = "<a><b>1</b></a><a><b>2</b></a><a><b>3</b></a>"
ghci> scrapeStringLike html $ texts "a"
Just ["1","2","3"]
ghci> scrapeStringLike html $ texts ("a" // "b")
Just ["1","2","3"]

Which version of scalpel are you using? Do you have a specific example that exhibits the problem?

tetotechy commented 7 years ago

the problem arises when you use the "b" selector:

ghci> let html = "<a><b>1</b></a><a><b>2</b></a><a><b>3</b></a>"
ghci> scrapeStringLike html $ texts (tagSelector "b")
Just ["3","2","1"]
fimad commented 7 years ago

It looks like this may be fixed with #59.

I just tried patching the proposed fix in #59 and it results in Just ["1","2","3"] for all 3 cases.

fimad commented 7 years ago

This should now be fixed in v0.5.1.