function Floki.Selector.match?/2 is undefined or private.
{:readability, "~> 0.8.0"}
x = Readability.summarize("https://sergiotapia.me/pluralizing-strings-in-javascript-es6-b5d4d651d403")
Error:
15:40:05 web.1 | ** (UndefinedFunctionError) function Floki.Selector.match?/2 is undefined or private. Did you mean one of:
15:40:05 web.1 |
15:40:05 web.1 | * match?/3
15:40:05 web.1 |
15:40:05 web.1 | (floki) Floki.Selector.match?({"html", [], [{"head", [], [{"title", [], ["302 Found"]}]}, {"body", [{"bgcolor", "white"}], [{"center", [], [{"h1", [], ["302 Found"]}]}, {"hr", [], []}, {"center", [], ["nginx"]}]}]}, [%Floki.Selector{attributes: [], classes: [], combinator: nil, id: nil, namespace: nil, pseudo_classes: [], type: "p"}])
15:40:05 web.1 | (readability) lib/readability/helper.ex:84: anonymous fn/2 in Readability.Helper.candidate_tag?/1
15:40:05 web.1 | (elixir) lib/enum.ex:2732: Enum.do_any?/2
15:40:05 web.1 | (readability) lib/readability/candidate_finder.ex:54: Readability.CandidateFinder.candidate?/2
15:40:05 web.1 | (readability) lib/readability/candidate_finder.ex:27: Readability.CandidateFinder.find/3
15:40:05 web.1 | (readability) lib/readability/article_builder.ex:31: Readability.ArticleBuilder.build/2
15:40:05 web.1 | (readability) lib/readability.ex:79: Readability.summarize/2
15:40:05 web.1 | (myapp) lib/news/news.ex:30: MyApp.News.download_content/1
It looks like a 302 redirect error that Readability isn't capturing properly.
Which version of Floki are you using? The internal API of Floki is unstable, and Floki.Selector.match?/2 doesn't exist on the latest release.
You'll need to use Floki < 0.16 (A 0.15 or older version).
@jonzlin95 Do you mean I need to bring in Floki manually in my dependency list?
Just check your mix.lock file and make sure you're not running a version of Floki that's too new.
@jonzlin95 Thanks for the help! In my mix.lock file I have this:
"floki": {:hex, :floki, "0.14.0", "91a6be57349e10a63cf52d7890479a19012cef9185fa93c305d4fe42e6a50dee", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
I'm still getting strange Floki build error, like Readability is calling functions that don't exist in the Floki package.
** (FunctionClauseError) no function clause matching in Floki.HTMLTree.build/1
stacktrace:
(floki) lib/floki/html_tree.ex:14: Floki.HTMLTree.build(nil)
(floki) lib/floki/finder.ex:48: Floki.Finder.find_selectors/2
(floki) lib/floki/filter_out.ex:17: Floki.FilterOut.filter_out/2
(floki) lib/floki.ex:210: Floki.text/2
(readability) lib/readability/helper.ex:75: Readability.Helper.text_length/1
(readability) lib/readability/article_builder.ex:36: Readability.ArticleBuilder.build/2
Can you let me know what to put into my mix.exs file and what command to run to update my dependencies? I have a feeling Readability is still calling the newer version of floki for some reason.
I put this in my mix file to make sure I have the 0.14 version.
{:readability, "~> 0.8.0"},
{:floki, "~> 0.14.0"},
Is this the right way to do it?
Actually I see now that it's trying to build an HTML tree for nil. I wonder what's causing it to end up using nil. I know I'm passing the readability function a very long html string.
This is the HTML that I'm trying to parse.
https://gist.github.com/sergiotapia/6ea4f860f9c4759dec1036118ac38872
It looks like the Floki's internal method: filter_out(html_tree, "script") is returning nil. This may be fixed in newer versions of Floki. :(
@sergiotapia Some code changing is necessary for upgrade Floki dependency. Please feel free to make PR
I can't get result with that url, I get 302...do you have any other url that I can test???
using your url fails here this code in /readability/lib/readability.ex
%{status_code: _, body: raw, headers: headers} = HTTPoison.get!(url, [], httpoison_options)
here HTTPoison is not giving any result, actually you can check on iex
HTTPoison.get!("https://sergiotapia.me/pluralizing-strings-in-javascript-es6-b5d4d651d403", [], [])
and the result is 302...so I can't even get the floki error
Floki has been updated and works fine with the latest version. Also, Floki.Selector.match? is no longer used in the codebase, so possibly that issue is no longer relevant (at least I can't replicate it).
If you still have this issue, please open separate issue.