phantom_proxy 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,9 +48,11 @@ module PhantomJSProxy
48
48
 
49
49
  puts("Opened page: "+ /Open page: (.*?) END/.match(@dom)[1])
50
50
 
51
+ @ready = 503
52
+ dom_text = "Failed to load page"
53
+
51
54
  if /DONE_LOADING_URL/.match(@dom)
52
- @dom = @dom.split('PHANTOMJS_DOMDATA_WRITE:')[1];
53
- @dom = @dom.split('PHANTOMJS_DOMDATA_END')[0]
55
+ dom_text = getDOMText @dom
54
56
  if pictureOnly && File.exist?(picture)
55
57
  puts("File is there")
56
58
  @image = IO::File.open(picture, "rb") {|f| f.read }
@@ -59,15 +61,27 @@ module PhantomJSProxy
59
61
  puts("No file to load at: "+picture)
60
62
  @image = ""
61
63
  end
62
- @ready = true
63
- else
64
- @dom = "Failed to load page"
65
- puts("TOTAL FAIL")
64
+ @ready = 200
65
+ end
66
+ if /FAILED_LOADING_URL/.match(@dom)
67
+ @ready = getHTTPCode @dom
68
+ puts("LOAD_ERROR")
66
69
  end
67
- #puts("Return dom")
70
+ @dom = dom_text
68
71
  return @dom
69
72
  end
70
73
 
74
+ def getDOMText data
75
+ tmp = data.split('PHANTOMJS_DOMDATA_WRITE:')[1];
76
+ tmp = tmp.split('PHANTOMJS_DOMDATA_END')[0]
77
+ tmp
78
+ end
79
+
80
+ def getHTTPCode data
81
+ tmp = /FAILED_LOADING_URL: (.*?)FAILED_LOADING_URL_END/.match(data)[1]
82
+ tmp.to_i
83
+ end
84
+
71
85
  def getAsImageResponse(type='png')
72
86
  return "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Type: image/"+type+"\r\n\r\n"+@image;
73
87
  end
@@ -137,14 +137,14 @@ module PhantomJSProxy
137
137
  phJS.getUrl(url, picture, loadFrames)
138
138
 
139
139
  #Create the response
140
- if !phJS.ready
140
+ if phJS.ready != 200
141
141
  if !/favicon\.ico/.match(req.url())
142
142
  env['rack.errors'].write("Request FAILED\n")
143
143
  control_panel.add_special_request "@failed_requests"
144
144
  else
145
145
  control_panel.add_special_request "@favicon_requests"
146
146
  end
147
- resp = Rack::Response.new([], 503, {
147
+ resp = Rack::Response.new([], phJS.ready , {
148
148
  'Content-Type' => 'text/html'
149
149
  }) { |r|
150
150
  r.write(phJS.dom)
@@ -131,8 +131,8 @@ function main() {
131
131
  page.onResourceReceived = function (response) {
132
132
  if (response.stage == "end" && response.url == address && response.status != 200)
133
133
  {
134
- console.log('FAILED_LOADING_URL: '+response.status);
135
- phantom.exit();
134
+ console.log('FAILED_LOADING_URL: '+response.status+'FAILED_LOADING_URL_END');
135
+ //phantom.exit();
136
136
  }
137
137
  };
138
138
 
metadata CHANGED
@@ -1,56 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: phantom_proxy
3
- version: !ruby/object:Gem::Version
4
- version: 1.2.6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 7
10
+ version: 1.2.7
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Daniel Sudmann
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-06 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-09-17 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: thin
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 1.3.1
22
- type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 25
30
+ segments:
31
+ - 1
32
+ - 3
33
+ - 1
29
34
  version: 1.3.1
30
- - !ruby/object:Gem::Dependency
31
- name: ruby-hmac
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 0.4.0
38
35
  type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: ruby-hmac
39
39
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 0
48
+ - 4
49
+ - 0
45
50
  version: 0.4.0
46
- description: This is a phyntonjs Proxy it allows you to fetch webpages and execute
47
- javascript in them.
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: This is a phyntonjs Proxy it allows you to fetch webpages and execute javascript in them.
48
54
  email: suddani@googlemail.com
49
- executables:
55
+ executables:
50
56
  - phantom_proxy
51
57
  extensions: []
58
+
52
59
  extra_rdoc_files: []
53
- files:
60
+
61
+ files:
54
62
  - lib/phantom_proxy/phantomjsserver.rb
55
63
  - lib/phantom_proxy/phantomjs_control_panel.rb
56
64
  - lib/phantom_proxy/phantomjs.rb
@@ -58,33 +66,43 @@ files:
58
66
  - lib/phantom_proxy/scripts/proxy.js
59
67
  - lib/phantom_proxy/config.ru
60
68
  - lib/phantom_proxy/web/control_panel.html
61
- - lib/phantom_proxy/scripts/test
62
69
  - lib/phantom_proxy/install/phproxy
63
70
  - bin/phantom_proxy
64
71
  - README.rdoc
65
72
  - Gemfile
73
+ has_rdoc: true
66
74
  homepage: http://experteer.com
67
75
  licenses: []
76
+
68
77
  post_install_message:
69
78
  rdoc_options: []
70
- require_paths:
79
+
80
+ require_paths:
71
81
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
82
+ required_ruby_version: !ruby/object:Gem::Requirement
73
83
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
92
  none: false
80
- requirements:
81
- - - ! '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
84
100
  requirements: []
101
+
85
102
  rubyforge_project:
86
- rubygems_version: 1.8.19
103
+ rubygems_version: 1.5.2
87
104
  signing_key:
88
105
  specification_version: 3
89
106
  summary: This is a phantomjs Proxy
90
107
  test_files: []
108
+
@@ -1,3 +0,0 @@
1
- Open page: https://hp.taleo.net/careersection/2/jobdetail.ftt?lang=en&job=1&, lang=en&job=1& END
2
- start openning page
3
- FAILED_LOADING_URL: 404