Class: AnswersEngine::Client::ScraperJobPage
- Inherits:
-
Base
- Object
- Base
- AnswersEngine::Client::ScraperJobPage
show all
- Defined in:
- lib/answersengine/client/scraper_job_page.rb
Instance Method Summary
collapse
-
#all(scraper_name, opts = {}) ⇒ Object
-
#enqueue(scraper_name, method, url, opts = {}) ⇒ Object
-
#find(scraper_name, gid) ⇒ Object
-
#refetch(scraper_name, opts = {}) ⇒ Object
-
#refetch_by_job(job_id, opts = {}) ⇒ Object
-
#reparse(scraper_name, opts = {}) ⇒ Object
-
#reparse_by_job(job_id, opts = {}) ⇒ Object
-
#update(scraper_name, gid, opts = {}) ⇒ Object
Methods inherited from Base
#auth_token, #auth_token=, #env_api_url, env_auth_token, #initialize
Instance Method Details
#all(scraper_name, opts = {}) ⇒ Object
8
9
10
11
|
# File 'lib/answersengine/client/scraper_job_page.rb', line 8
def all(scraper_name, opts={})
params = @options.merge(opts)
self.class.get("/scrapers/#{scraper_name}/current_job/pages", params)
end
|
#enqueue(scraper_name, method, url, opts = {}) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/answersengine/client/scraper_job_page.rb', line 44
def enqueue(scraper_name, method, url, opts={})
body = {}
body[:method] = method != "" ? method : "GET"
body[:url] = url
body[:page_type] = opts[:page_type] if opts[:page_type]
body[:priority] = opts[:priority] if opts[:priority]
body[:fetch_type] = opts[:fetch_type] if opts[:fetch_type]
body[:body] = opts[:body] if opts[:body]
body[:headers] = opts[:headers] if opts[:headers]
body[:vars] = opts[:vars] if opts[:vars]
body[:force_fetch] = opts[:force_fetch] if opts[:force_fetch]
body[:freshness] = opts[:freshness] if opts[:freshness]
body[:ua_type] = opts[:ua_type] if opts[:ua_type]
body[:no_redirect] = opts[:no_redirect] if opts[:no_redirect]
body[:cookie] = opts[:cookie] if opts[:cookie]
params = @options.merge({body: body.to_json})
self.class.post("/scrapers/#{scraper_name}/current_job/pages", params)
end
|
#find(scraper_name, gid) ⇒ Object
4
5
6
|
# File 'lib/answersengine/client/scraper_job_page.rb', line 4
def find(scraper_name, gid)
self.class.get("/scrapers/#{scraper_name}/current_job/pages/#{gid}", @options)
end
|
#refetch(scraper_name, opts = {}) ⇒ Object
24
25
26
27
|
# File 'lib/answersengine/client/scraper_job_page.rb', line 24
def refetch(scraper_name, opts={})
params = @options.merge(opts)
self.class.put("/scrapers/#{scraper_name}/current_job/pages/refetch", params)
end
|
#refetch_by_job(job_id, opts = {}) ⇒ Object
29
30
31
32
|
# File 'lib/answersengine/client/scraper_job_page.rb', line 29
def refetch_by_job(job_id, opts={})
params = @options.merge(opts)
self.class.put("/jobs/#{job_id}/pages/refetch", params)
end
|
#reparse(scraper_name, opts = {}) ⇒ Object
34
35
36
37
|
# File 'lib/answersengine/client/scraper_job_page.rb', line 34
def reparse(scraper_name, opts={})
params = @options.merge(opts)
self.class.put("/scrapers/#{scraper_name}/current_job/pages/reparse", params)
end
|
#reparse_by_job(job_id, opts = {}) ⇒ Object
39
40
41
42
|
# File 'lib/answersengine/client/scraper_job_page.rb', line 39
def reparse_by_job(job_id, opts={})
params = @options.merge(opts)
self.class.put("/jobs/#{job_id}/pages/reparse", params)
end
|
#update(scraper_name, gid, opts = {}) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/answersengine/client/scraper_job_page.rb', line 13
def update(scraper_name, gid, opts={})
body = {}
body[:page_type] = opts[:page_type] if opts[:page_type]
body[:priority] = opts[:priority] if opts[:priority]
body[:vars] = opts[:vars] if opts[:vars]
params = @options.merge({body: body.to_json})
self.class.put("/scrapers/#{scraper_name}/current_job/pages/#{gid}", params)
end
|