-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from ElixirTeSS/fix_portugal_scraper
Fix Portugal scraper
- Loading branch information
Showing
6 changed files
with
82 additions
and
54 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
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 |
---|---|---|
@@ -1,40 +1,64 @@ | ||
|
||
class IntermineScraper < Tess::Scrapers::Scraper | ||
|
||
def self.config | ||
{ | ||
name: 'Intermine Scraper', | ||
index_page: 'http://intermine.org/tutorials/' | ||
name: "Intermine Scraper", | ||
index_page: "http://intermine.org/tutorials/", | ||
} | ||
end | ||
|
||
def scrape | ||
cp = add_content_provider(Tess::API::ContentProvider.new( | ||
title: "InterMine", #name | ||
url: "http://intermine.org", #url | ||
image_url: "https://cdn.rawgit.com/intermine/design-materials/ff1ec6bf/logos/intermine/intermine-300x37.png", #logo | ||
description: "nterMine integrates biological data sources, making it easy to query and analyse data.", #description | ||
content_provider_type: :project, | ||
node_name: :'UK' | ||
)) | ||
cp = add_content_provider(Tess::API::ContentProvider.new( | ||
title: "InterMine", #name | ||
url: "http://intermine.org", #url | ||
image_url: "https://cdn.rawgit.com/intermine/design-materials/ff1ec6bf/logos/intermine/intermine-300x37.png", #logo | ||
description: "nterMine integrates biological data sources, making it easy to query and analyse data.", #description | ||
content_provider_type: :project, | ||
node_name: :'UK', | ||
)) | ||
|
||
#page = Nokogiri::HTML.parse(open(config[:index_page]).read) | ||
index = "http://intermine.org/tutorials/" | ||
page = Nokogiri::HTML.parse(open(index).read) | ||
tutorials = page.xpath("/html/body/main/ul/li") | ||
|
||
#page = Nokogiri::HTML.parse(open(config[:index_page]).read) | ||
index = 'http://intermine.org/tutorials/' | ||
page = Nokogiri::HTML.parse(open(index).read) | ||
tutorials = page.xpath('/html/body/main/ul/li') | ||
|
||
tutorials.each do |tutorial| | ||
url = tutorial.children.first.attributes['href'].value | ||
title = tutorial.text.split('-').first | ||
description = tutorial.text | ||
event = Tess::API::Material.new( | ||
title: title, | ||
url: url, | ||
content_provider: cp, | ||
short_description: description, | ||
keywords: title.split(' ').first | ||
) | ||
add_material(event) | ||
end | ||
end | ||
tutorials.each do |tutorial| | ||
if !tutorial.children.first.attributes["href"].nil? | ||
url = tutorial.children.first.attributes["href"].value | ||
title = tutorial.text.split("-").first | ||
description = tutorial.text | ||
event = Tess::API::Material.new( | ||
title: title, | ||
url: url, | ||
content_provider: cp, | ||
short_description: description, | ||
keywords: title.split(" ").first, | ||
) | ||
add_material(event) | ||
end | ||
end | ||
|
||
#page = Nokogiri::HTML.parse(open(config[:index_page]).read) | ||
index = "http://intermine.org/training-workshops/" | ||
page = Nokogiri::HTML.parse(open(index).read) | ||
tutorials = page.xpath("/html/body/div/section/ul/li/a") | ||
tutorials.each do |tutorial| | ||
if !tutorial.attributes["href"].nil? | ||
url = tutorial.attributes["href"].value | ||
# Complete relative URL paths | ||
if !url.include? "http" | ||
url = index + url | ||
end | ||
title = tutorial.children.text | ||
description = title | ||
event = Tess::API::Material.new( | ||
title: title, | ||
url: url, | ||
content_provider: cp, | ||
short_description: description, | ||
keywords: title.split(" ").first, | ||
) | ||
add_material(event) | ||
end | ||
end | ||
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