-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add parser of html links #87
Merged
Merged
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c55daf8
Add floki to dependencies
nappex 5c36f40
Add test for parsing html links
nappex 9c9a668
Add parser of html links
nappex 17612b2
Merge branch 'master' into links-parser
Glutexo 6d7a44f
Add header to toolbox dependencies
nappex 7d55762
Move parser.ex to spider_html.ex
nappex fff0bb9
Rename document to hmtl
nappex def56d9
Make from html sigil a constant
nappex 6422b03
Fix sigil content, indentation and remove double qoutes
nappex 9d48de1
Add a tag without href to test if error will invoke
nappex 14a3f1a
Fix path to module and function find_links
nappex f38c140
Rename var result to links
nappex 2b8df13
Add describe to test
nappex d5b753c
Rename test file to spider_html, to keep changes from parser to spider
nappex 5068ba6
Merge branch 'master' into links-parser
nappex af9da82
Fix slash from left to right
nappex 57f681c
Update mix.exs suitable name of toolbox
nappex ae8dc30
Update test/spider_html_test.exs
nappex 4a53137
Update test/spider_html_test.exs
nappex 485c904
Fix floki definition for mix.exs to be consistent
nappex 792a512
Update test/spider_html_test.exs
nappex 36a9324
Add other tag with href than 'a' to test if we collect href only for …
nappex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule Parser do | ||
def html_links(document) do | ||
Floki.parse_document!(document) | ||
|> Floki.find("a") | ||
|> Floki.attribute("href") | ||
nappex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule ParseTest do | ||
use ExUnit.Case | ||
|
||
@urls [ | ||
nappex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"http://onigumo.local/hello.html", | ||
"http://onigumo.local/bye.html" | ||
] | ||
|
||
test("Parsing values of href attributes in html links") do | ||
document = ~s("<!doctype html> | ||
nappex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<html> | ||
<body> | ||
<section id="content"> | ||
<p class="headline">Floki</p> | ||
<a href="http://onigumo.local/hello.html">Hello</a> | ||
<a href="http://onigumo.local/bye.html">Bye</a> | ||
<span data-model="user">onigumo</span> | ||
</section> | ||
</body> | ||
</html>") | ||
nappex marked this conversation as resolved.
Show resolved
Hide resolved
nappex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
result = Parser.html_links(document) | ||
nappex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert result == @urls | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤨