marketplace_opportunity_scraper 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +1 -1
- data/Gemfile.lock +1 -1
- data/fixtures/cassettes/MarketplaceOpportunityScraper_Opportunity/_all/gets_data_that_is_not_on_the_homepage.yml +2698 -0
- data/fixtures/cassettes/MarketplaceOpportunityScraper_Opportunity/_all/gets_the_correct_opportunity_data.yml +2773 -0
- data/fixtures/cassettes/MarketplaceOpportunityScraper_Opportunity/_all/returns_all_open_opportunities.yml +2773 -0
- data/fixtures/cassettes/MarketplaceOpportunityScraper_Opportunity/_all/when_type_is_specified/returns_the_correct_opportunities.yml +1498 -0
- data/lib/marketplace_opportunity_scraper/opportunity.rb +3 -19
- data/lib/marketplace_opportunity_scraper/version.rb +1 -1
- metadata +1 -1
@@ -13,6 +13,7 @@ module MarketplaceOpportunityScraper
|
|
13
13
|
question_deadline
|
14
14
|
closing
|
15
15
|
description
|
16
|
+
expected_start_date
|
16
17
|
].freeze
|
17
18
|
|
18
19
|
attr_reader *ATTRIBUTES
|
@@ -62,10 +63,6 @@ module MarketplaceOpportunityScraper
|
|
62
63
|
['digital-outcomes', 'digital-specialists', 'user-research-participants']
|
63
64
|
end
|
64
65
|
|
65
|
-
def self.get_date(date)
|
66
|
-
Date.parse date.text.split(':').last
|
67
|
-
end
|
68
|
-
|
69
66
|
def self.opportunity_from_id(id)
|
70
67
|
url = BASE_URL + '/digital-outcomes-and-specialists/opportunities/' + id.to_s
|
71
68
|
page = mechanize.get(url)
|
@@ -82,6 +79,7 @@ module MarketplaceOpportunityScraper
|
|
82
79
|
published: Date.parse(text_from_label(page, 'Published')),
|
83
80
|
question_deadline: Date.parse(text_from_label(page, 'Deadline for asking questions')),
|
84
81
|
closing: Date.parse(text_from_label(page, 'Closing date for applications')),
|
82
|
+
expected_start_date: Date.parse(text_from_label(page, 'Latest start date')),
|
85
83
|
description: text_from_label(page, 'Summary of the work')
|
86
84
|
}
|
87
85
|
|
@@ -90,23 +88,9 @@ module MarketplaceOpportunityScraper
|
|
90
88
|
|
91
89
|
def self.opportunity_from_search_result(element)
|
92
90
|
title = element.at('.search-result-title')
|
93
|
-
important_metadata = element.search('ul.search-result-important-metadata li')
|
94
|
-
dates = element.search('ul.search-result-metadata')[1].search('li')
|
95
91
|
url = BASE_URL + title.at('a').attributes['href'].value
|
96
92
|
|
97
|
-
|
98
|
-
id: url.split('/').last.to_i,
|
99
|
-
title: title.text.strip,
|
100
|
-
url: url,
|
101
|
-
buyer: important_metadata[0].text.strip,
|
102
|
-
location: important_metadata[1].text.strip,
|
103
|
-
published: get_date(dates[0]),
|
104
|
-
question_deadline: get_date(dates[1]),
|
105
|
-
closing: get_date(dates[2]),
|
106
|
-
description: element.at('.search-result-excerpt').text.strip
|
107
|
-
}
|
108
|
-
|
109
|
-
new(attrs)
|
93
|
+
opportunity_from_id(url.split('/').last.to_i)
|
110
94
|
end
|
111
95
|
|
112
96
|
def self.text_from_label(page, label)
|