-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependecies-update
- Loading branch information
Showing
11 changed files
with
65 additions
and
20 deletions.
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 |
---|---|---|
|
@@ -25,4 +25,5 @@ onigumo-*.tar | |
# Temporary files, for example, from tests. | ||
/tmp/ | ||
|
||
onigumo | ||
# Ignore onigumo escript file | ||
/onigumo |
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 Onigumo.CLI do | ||
def main([component]) do | ||
module = Module.safe_concat("Onigumo", component) | ||
root_path = File.cwd!() | ||
module.main(root_path) | ||
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 was deleted.
Oops, something went wrong.
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 Onigumo.Spider.HTML do | ||
def find_links(document) do | ||
Floki.parse_document!(document) | ||
|> Floki.find("a") | ||
|> Floki.attribute("href") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
defmodule Hash do | ||
defmodule Onigumo.Utilities.Hash do | ||
def md5(data, fmt) do | ||
hash(:md5, data) | ||
|> format(fmt) | ||
|
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
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,30 @@ | ||
defmodule SpiderHtmlTest do | ||
use ExUnit.Case | ||
|
||
@urls [ | ||
"http://onigumo.local/hello.html", | ||
"http://onigumo.local/bye.html" | ||
] | ||
@html ~s(<!doctype html> | ||
<html> | ||
<head> | ||
<link href="/media/examples/link-element-example.css" rel="stylesheet"> | ||
</head> | ||
<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> | ||
<a id="nothing"></a> | ||
<span data-model="user">onigumo</span> | ||
</section> | ||
</body> | ||
</html>) | ||
|
||
describe("Onigumo.Spider.HTML.find_links/1") do | ||
test("find links in href attributes of 'a' tags") do | ||
links = Onigumo.Spider.HTML.find_links(@html) | ||
assert links == @urls | ||
end | ||
end | ||
end |