brand2csv 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +117 -93
- data/.gemtest +0 -0
- data/.gitignore +0 -10
- data/.rspec +0 -1
- data/.travis.yml +0 -14
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -76
- data/History.txt +0 -111
- data/LICENCE.txt +0 -515
- data/Manifest.txt +0 -54
- data/README.md +0 -27
- data/Rakefile +0 -25
- data/bin/brand2csv +0 -100
- data/lib/brand2csv.rb +0 -590
- data/lib/brand2csv/version.rb +0 -3
- data/logs/aspen_08_08_1986.html +0 -598
- data/logs/post.rohdaten.httpfox +0 -1
- data/logs/post.rohdaten.mechanize +0 -1
- data/logs/protocol_swissreg.log +0 -86
- data/logs/result_01.10.2005.jsp +0 -598
- data/logs/sr1.jsp +0 -449
- data/logs/sr3.jsp +0 -598
- data/logs/start.jsp +0 -350
- data/logs/start2.jsp +0 -434
- data/protocol.2013.05.12.textile +0 -56
- data/protocol.2013.05.15.textile +0 -49
- data/protocol.2013.05.21.textile +0 -84
- data/spec/brand2csv_spec.rb +0 -62
- data/spec/csv_spec.rb +0 -27
- data/spec/data/aspectra/detail_00001_P-480296.html +0 -531
- data/spec/data/aspectra/detail_00002_P-482236.html +0 -531
- data/spec/data/aspectra/detail_00003_641074.html +0 -539
- data/spec/data/aspectra/first_results.html +0 -600
- data/spec/data/einfache_suche.html +0 -434
- data/spec/data/erweiterte_suche.html +0 -446
- data/spec/data/main.html +0 -350
- data/spec/data/result_short.html +0 -606
- data/spec/data/resultate_1.html +0 -446
- data/spec/data/resultate_2.html +0 -446
- data/spec/data/urner_wildheu/detail_00001_57862.2013.html +0 -516
- data/spec/data/urner_wildheu/first_results.html +0 -598
- data/spec/data/vereinfachte_1.html +0 -847
- data/spec/data/vereinfachte_detail_33.html +0 -516
- data/spec/detail_spec.rb +0 -28
- data/spec/short_spec.rb +0 -55
- data/spec/simple_search.rb +0 -43
- data/spec/spec_helper.rb +0 -34
- data/spec/support/core_ext/kernel.rb +0 -26
- data/spec/support/server_mock_helper.rb +0 -142
- data/spec/swissreg_spec.rb +0 -44
- data/spec/trademark_numbers_spec.rb +0 -21
- data/spec/utilities_spec.rb +0 -83
- data/spike.rb +0 -491
- data/spike_mechanize_swissreg.rb +0 -312
- data/spike_watir.rb +0 -58
- data/swissreg.rb +0 -75
data/spike_mechanize_swissreg.rb
DELETED
@@ -1,312 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'mechanize'
|
3
|
-
require 'prettyprint'
|
4
|
-
require 'optparse'
|
5
|
-
|
6
|
-
Useage = "Usage: #{File.basename(__FILE__)} timespan
|
7
|
-
Find all brands registered in switzerland during the given timespan.
|
8
|
-
The following examples valid timespan periods:
|
9
|
-
1.10.2005
|
10
|
-
1.10.2005-31.10.2005
|
11
|
-
1.10.2005, 5.10.2005-31.10.2005
|
12
|
-
"
|
13
|
-
OptionParser.new do |opts|
|
14
|
-
opts.banner = Useage
|
15
|
-
opts.on("-h", "--help", "Show this help") do |v|
|
16
|
-
puts opts
|
17
|
-
exit
|
18
|
-
end
|
19
|
-
end.parse!
|
20
|
-
unless ARGV
|
21
|
-
puts Useage
|
22
|
-
exit 1
|
23
|
-
end
|
24
|
-
|
25
|
-
timespan = ARGV[0]
|
26
|
-
|
27
|
-
module Brand2csv do
|
28
|
-
# Weitere gesehene Fehler
|
29
|
-
bekannteFehler =
|
30
|
-
['Das Datum ist ung', # ültig'
|
31
|
-
'Es wurden keine Daten gefunden.',
|
32
|
-
'Die Suchkriterien sind teilweise unzul', # ässig',
|
33
|
-
'Geben Sie mindestens ein Suchkriterium ein',
|
34
|
-
'Die Suche wurde abgebrochen, da die maximale Suchzeit von 60 Sekunden',
|
35
|
-
]
|
36
|
-
end
|
37
|
-
$base_uri = 'https://www.swissreg.ch'
|
38
|
-
$start_uri = "#{$base_uri}/srclient/faces/jsp/start.jsp"
|
39
|
-
|
40
|
-
def writeResponse(filename, body)
|
41
|
-
ausgabe = File.open(filename, 'w+')
|
42
|
-
ausgabe.puts body
|
43
|
-
ausgabe.close
|
44
|
-
end
|
45
|
-
|
46
|
-
def view_state(response)
|
47
|
-
if match = /javax.faces.ViewState.*?value="([^"]+)"/u.match(response.force_encoding('utf-8'))
|
48
|
-
match[1]
|
49
|
-
else
|
50
|
-
""
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def parse_swissreg(timespan = "01.06.2007-10.06.2007", # sollte 377 Treffer ergeben, für 01.06.2007-10.06.2007, 559271 wurde in diesem Zeitraum registriert
|
55
|
-
marke = nil,
|
56
|
-
nummer =nil) # nummer = "559271" ergibt genau einen treffer
|
57
|
-
|
58
|
-
a = Mechanize.new { |agent|
|
59
|
-
# agent.user_agent_alias = 'Mac Safari'
|
60
|
-
agent.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0'
|
61
|
-
# agent.redirection_limit = 5
|
62
|
-
agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
63
|
-
}
|
64
|
-
|
65
|
-
page = a.get $start_uri # get a cookie for the session
|
66
|
-
content = a.get_file $start_uri
|
67
|
-
FileUtils.makedirs 'mechanize'
|
68
|
-
writeResponse('mechanize/main.html', content)
|
69
|
-
state = view_state(content)
|
70
|
-
data = [
|
71
|
-
["autoScroll", "0,0"],
|
72
|
-
["id_swissreg:_link_hidden_", ""],
|
73
|
-
["id_swissreg_SUBMIT", "1"],
|
74
|
-
["id_swissreg:_idcl", "id_swissreg_sub_nav_ipiNavigation_item0"],
|
75
|
-
["javax.faces.ViewState", state],
|
76
|
-
]
|
77
|
-
|
78
|
-
content = a.post($start_uri, data)
|
79
|
-
writeResponse('mechanize/einfache_suche.html', content.body)
|
80
|
-
|
81
|
-
data = [
|
82
|
-
["autoScroll", "0,0"],
|
83
|
-
["id_swissreg:_link_hidden_", ""],
|
84
|
-
["id_swissreg_SUBMIT", "1"],
|
85
|
-
["id_swissreg:_idcl", "id_swissreg_sub_nav_ipiNavigation_item0_item3"],
|
86
|
-
["javax.faces.ViewState", state],
|
87
|
-
]
|
88
|
-
# sr1 ist die einfache suche, sr3 die erweiterte Suche
|
89
|
-
path = "/srclient/faces/jsp/trademark/sr3.jsp"
|
90
|
-
response = a.post($base_uri + path, data)
|
91
|
-
writeResponse('mechanize/erweiterte_suche.html', response.body)
|
92
|
-
# Bis hier alles okay
|
93
|
-
criteria = [
|
94
|
-
["autoScroll", "0,0"],
|
95
|
-
["id_swissreg:_link_hidden_", ""],
|
96
|
-
# "id_swissreg:mainContent:id_cbxFormatChoice" 2 = Publikationsansicht 1 = Registeransicht
|
97
|
-
["id_swissreg:mainContent:id_cbxFormatChoice", "1"],
|
98
|
-
["id_swissreg:mainContent:id_ckbTMState", "1"], # "Hängige Gesuche 1
|
99
|
-
# ["id_swissreg:mainContent:id_ckbTMState", "2"], # "Gelöschte Gesuche 2
|
100
|
-
["id_swissreg:mainContent:id_ckbTMState", "3"], # aktive Marken 3
|
101
|
-
# ["id_swissreg:mainContent:id_ckbTMState", "4"], # gelöschte Marken 4
|
102
|
-
["id_swissreg:mainContent:id_cbxCountry", "CH"], # Auswahl Länder _ALL
|
103
|
-
# ["id_swissreg:mainContent:id_txf_tm_no", ""], # Marken Nr
|
104
|
-
["id_swissreg:mainContent:id_txf_app_no", ""], # Gesuch Nr.
|
105
|
-
["id_swissreg:mainContent:id_txf_applicant", ""], # Inhaber/in
|
106
|
-
["id_swissreg:mainContent:id_txf_agent", ""], # Vertreter/in
|
107
|
-
["id_swissreg:mainContent:id_txf_licensee", ""], # Lizenznehmer
|
108
|
-
["id_swissreg:mainContent:id_txf_nizza_class", ""], # Nizza Klassifikation Nr.
|
109
|
-
# ["id_swissreg:mainContent:id_txf_appDate", timespan], # Hinterlegungsdatum
|
110
|
-
["id_swissreg:mainContent:id_txf_expiryDate", ""], # Ablauf Schutzfrist
|
111
|
-
# Markenart: Individualmarke 1 Kollektivmarke 2 Garantiemarke 3
|
112
|
-
["id_swissreg:mainContent:id_cbxTMTypeGrp", "_ALL"], # Markenart
|
113
|
-
["id_swissreg:mainContent:id_cbxTMForm", "_ALL"], # Markentyp
|
114
|
-
["id_swissreg:mainContent:id_cbxTMColorClaim", "_ALL"], # Farbanspruch
|
115
|
-
["id_swissreg:mainContent:id_txf_pub_date", ""], # Publikationsdatum
|
116
|
-
# name="id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_applicant"], # /> Inhaber/in</label></td>
|
117
|
-
|
118
|
-
# info zu Publikationsgrund id_swissreg:mainContent:id_ckbTMPubReason
|
119
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", "1"], #Neueintragungen
|
120
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", "2"], #Berichtigungen
|
121
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", "3"], #Verlängerungen
|
122
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", "4"], #Löschungen
|
123
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", "5"], #Inhaberänderungen
|
124
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", "6"], #Vertreteränderungen
|
125
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", "7"], #Lizenzänderungen
|
126
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", "8"], #Weitere Registeränderungen
|
127
|
-
["id_swissreg:mainContent:id_ckbTMEmptyHits", "0"], # Leere Trefferliste anzeigen
|
128
|
-
|
129
|
-
# Angezeigte Spalten "id_swissreg:mainContent:id_ckbTMChoice"
|
130
|
-
["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_tm_text"], # Marke
|
131
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_state"], # Status
|
132
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_nizza_class"], # Nizza Klassifikation Nr.
|
133
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_no"], # disabled="disabled"], # Nummer
|
134
|
-
["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_applicant"], # Inhaber/in
|
135
|
-
["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_country"], # Land (Inhaber/in)
|
136
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_agent"], # Vertreter/in
|
137
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_licensee"], # Lizenznehmer/in
|
138
|
-
["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_app_date"], # Hinterlegungsdatum
|
139
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_expiry_date"], # Ablauf Schutzfrist
|
140
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_type_grp"], # Markenart
|
141
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_form"], # Markentyp
|
142
|
-
# ["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_color_claim"], # Farbanspruch
|
143
|
-
|
144
|
-
["id_swissreg:mainContent:id_cbxHitsPerPage", "100"], # Treffer pro Seite
|
145
|
-
["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_applicant"],
|
146
|
-
["id_swissreg:mainContent:sub_fieldset:id_submit", "suchen"],
|
147
|
-
# ["id_swissreg:mainContent:sub_fieldset:id_reset", "0"],
|
148
|
-
["id_swissreg_SUBMIT", "1"],
|
149
|
-
["javax.faces.ViewState", state],
|
150
|
-
]
|
151
|
-
if marke # Wortlaut der Marke
|
152
|
-
puts "Marke ist #{marke}"
|
153
|
-
criteria << ["id_swissreg:mainContent:id_txf_tm_text", marke]
|
154
|
-
else
|
155
|
-
puts "Keine Marke spezifiziert. #{marke.inspect}"
|
156
|
-
criteria << ["id_swissreg:mainContent:id_txf_tm_text", ""]
|
157
|
-
end
|
158
|
-
if timespan # Hinterlegungsdatum
|
159
|
-
puts "Hinterlegungsdatum ist #{timespan}"
|
160
|
-
criteria << ["id_swissreg:mainContent:id_txf_appDate", timespan] # Hinterlegungsdatum
|
161
|
-
else
|
162
|
-
puts "Keine Hinterlegungsdatum spezifiziert. #{timespan.inspect}"
|
163
|
-
criteria << ["id_swissreg:mainContent:id_txf_appDate", ""] # Hinterlegungsdatum
|
164
|
-
end
|
165
|
-
if nummer
|
166
|
-
puts "nummer ist #{timespan}"
|
167
|
-
criteria << ["id_swissreg:mainContent:id_txf_tm_no", nummer]
|
168
|
-
else
|
169
|
-
puts "Keine nummer spezifiziert. #{timespan.inspect}"
|
170
|
-
criteria << ["id_swissreg:mainContent:id_txf_tm_no", ""]
|
171
|
-
end
|
172
|
-
|
173
|
-
path = "/srclient/faces/jsp/trademark/sr3.jsp"
|
174
|
-
response = a.post($base_uri + path, criteria)
|
175
|
-
writeResponse('mechanize/resultate_1.html', response.body)
|
176
|
-
criteria<<['id_swissreg:mainContent:scroll_1idx2', 'idx2']
|
177
|
-
if false # does not work, returns to the extended search path
|
178
|
-
response = a.post($base_uri + path, criteria)
|
179
|
-
writeResponse('mechanize/resultate_2.html', response.body)
|
180
|
-
end
|
181
|
-
|
182
|
-
if false # Will try later
|
183
|
-
path = "/srclient/faces/jsp/trademark/sr3.jsp"
|
184
|
-
data_detail = [
|
185
|
-
["autoScroll", "0,0"],
|
186
|
-
["id_swissreg:_link_hidden_", ""],
|
187
|
-
["id_swissreg_SUBMIT", "1"],
|
188
|
-
["id_swissreg:_idcl", "id_swissreg_sub_nav_ipiNavigation_item0_item3"],
|
189
|
-
["javax.faces.ViewState", state],
|
190
|
-
]
|
191
|
-
|
192
|
-
response = a.post($base_uri + path, data_detail)
|
193
|
-
https://www.swissreg.ch/srclient/faces/jsp/trademark/sr30.jsp
|
194
|
-
end
|
195
|
-
end #
|
196
|
-
# parse_swissreg("01.06.2007-10.06.2007" , 'asp*')
|
197
|
-
require 'csv'
|
198
|
-
$results = []
|
199
|
-
$errors = Hash.new
|
200
|
-
|
201
|
-
class Marke < Struct.new(:name, :markennummer, :inhaber, :land, :hinterlegungsdatum, :zeile_1, :zeile_2, :zeile_3, :zeile_4, :plz, :ort)
|
202
|
-
end
|
203
|
-
|
204
|
-
AddressRegexp = /^(\d\d\d\d)\W*(.*)/
|
205
|
-
LineSplit = ', '
|
206
|
-
DefaultCountry = 'Schweiz'
|
207
|
-
|
208
|
-
def parseAddress(nummer, inhaber)
|
209
|
-
zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, zeile_6 = inhaber.split(LineSplit)
|
210
|
-
ort = nil
|
211
|
-
plz = nil
|
212
|
-
if m = AddressRegexp.match(zeile_2)
|
213
|
-
zeile_2 = nil
|
214
|
-
plz = m[1]; ort = m[2]
|
215
|
-
elsif m = AddressRegexp.match(zeile_3)
|
216
|
-
zeile_3 = nil
|
217
|
-
plz = m[1]; ort = m[2]
|
218
|
-
elsif m = AddressRegexp.match(zeile_4)
|
219
|
-
zeile_4 = nil
|
220
|
-
plz = m[1]; ort = m[2]
|
221
|
-
elsif m = AddressRegexp.match(zeile_5)
|
222
|
-
zeile_5 = nil
|
223
|
-
plz = m[1]; ort = m[2]
|
224
|
-
else
|
225
|
-
puts "Achtung! Konnte Marke #{nummer} mit Inhaber #{inhaber} nicht parsen" if $VERBOSE
|
226
|
-
return nil, nil, nil, nil, nil, nil, nil, nil
|
227
|
-
end
|
228
|
-
return zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, zeile_6, plz, ort
|
229
|
-
end
|
230
|
-
|
231
|
-
def fetchDetails(nummer) # takes a long time!
|
232
|
-
doc = nil
|
233
|
-
filename = "mechanize/detail_#{nummer}.html"
|
234
|
-
unless File.exists?(filename)
|
235
|
-
url = "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr300.jsp?language=de§ion=tm&id=#{nummer}"
|
236
|
-
a = Mechanize.new { |agent|
|
237
|
-
# agent.user_agent_alias = 'Mac Safari'
|
238
|
-
agent.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0'
|
239
|
-
# agent.redirection_limit = 5
|
240
|
-
agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
241
|
-
}
|
242
|
-
page = a.get $start_uri # get a cookie for the session
|
243
|
-
content = a.get_file url
|
244
|
-
writeResponse("mechanize/detail_#{nummer}.html", content)
|
245
|
-
end
|
246
|
-
doc = Nokogiri::Slop(File.open(filename))
|
247
|
-
path_name = "//html/body/form/div/div/fieldset/div/table/tbody/tr/td"
|
248
|
-
elem = doc.xpath(path_name).first
|
249
|
-
counter = 0
|
250
|
-
doc.xpath(path_name).each{
|
251
|
-
|td|
|
252
|
-
pp "#{counter}: #{td.text}" if $VERBOSE
|
253
|
-
counter += 1
|
254
|
-
next unless /^inhaber/i.match(td.text)
|
255
|
-
zeilen = []
|
256
|
-
doc.xpath(path_name)[counter].children.each{ |child| zeilen << child.text.gsub(LineSplit,'. ') unless child.text.length == 0 } # avoid adding <br>
|
257
|
-
if info = $errors[nummer]
|
258
|
-
info.inhaber = zeilen.join(LineSplit)
|
259
|
-
info.zeile_1, info.zeile_2, info.zeile_3, info.zeile_4, zeile_5, zeile_6, info.plz, info.ort = parseAddress(nummer, info.inhaber)
|
260
|
-
$results << info
|
261
|
-
else
|
262
|
-
bezeichnung = doc.xpath(path_name)[15]
|
263
|
-
inhaber = zeilen.join(LineSplit)
|
264
|
-
zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, zeile_6, plz, ort = parseAddress(nummer, inhaber)
|
265
|
-
hinterlegungsdatum = doc.xpath(path_name)[7]
|
266
|
-
marke = Marke.new(bezeichnung, nummer, inhaber, DefaultCountry, hinterlegungsdatum, zeile_1, zeile_2, zeile_3, zeile_4, plz, ort )
|
267
|
-
$results << marke
|
268
|
-
end
|
269
|
-
}
|
270
|
-
end
|
271
|
-
|
272
|
-
def fetchresult(filename= 'mechanize/resultate_1.html')
|
273
|
-
nrFailures = 0
|
274
|
-
# doc = Nokogiri::Slop(inhalt)
|
275
|
-
doc = Nokogiri::Slop(File.open(filename))
|
276
|
-
path_name = "//html/body/form/div/div/fieldset/table/tbody/tr/td/table/tbody/tr"
|
277
|
-
elem = doc.xpath(path_name).first
|
278
|
-
doc.xpath(path_name).each{
|
279
|
-
|elem|
|
280
|
-
bezeichnung = elem.elements[1].text
|
281
|
-
land = elem.elements[4].text
|
282
|
-
next unless /#{DefaultCountry}/i.match(land)
|
283
|
-
inhaber = elem.elements[3].text
|
284
|
-
nummer = elem.elements[2].text
|
285
|
-
if bezeichnung.length == 0
|
286
|
-
bezeichnung = elem.children[1].children[0].children[0].children[0].attribute('src').to_s
|
287
|
-
end
|
288
|
-
zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, zeile_6, plz, ort = parseAddress(nummer, inhaber)
|
289
|
-
if zeile_1
|
290
|
-
$results << Marke.new(bezeichnung, elem.elements[2].text, elem.elements[3].text, land, elem.elements[5].text,
|
291
|
-
zeile_1, zeile_2, zeile_3, zeile_4, plz, ort )
|
292
|
-
else
|
293
|
-
nrFailures += 1
|
294
|
-
$errors[nummer] = Marke.new(bezeichnung, elem.elements[2].text, elem.elements[3].text, land, elem.elements[5].text,
|
295
|
-
zeile_1, zeile_2, zeile_3, zeile_4, plz, ort )
|
296
|
-
end
|
297
|
-
}
|
298
|
-
puts "Es gab #{nrFailures} Fehler beim lesen von #{filename}" if $VERBOSE
|
299
|
-
end
|
300
|
-
|
301
|
-
pp 1
|
302
|
-
parse_swissreg(timespan)
|
303
|
-
pp 2
|
304
|
-
fetchresult
|
305
|
-
$errors.each{
|
306
|
-
|markennummer, info|
|
307
|
-
fetchDetails(markennummer)
|
308
|
-
}
|
309
|
-
|
310
|
-
CSV.open('ausgabe.csv', 'w') do |csv|
|
311
|
-
$results.each{ |x| csv << x }
|
312
|
-
end
|
data/spike_watir.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
# require 'selenium'
|
4
|
-
require 'watir'
|
5
|
-
require 'watir-webdriver'
|
6
|
-
require 'fileutils'
|
7
|
-
require 'pp'
|
8
|
-
|
9
|
-
# zum schnell von Hand testen
|
10
|
-
# client = Selenium::WebDriver::Remote::Http::Default.new
|
11
|
-
# client.timeout = 180 # seconds – default is 60
|
12
|
-
|
13
|
-
$cnt = 1
|
14
|
-
def saveStep(b, cnt = $cnt)
|
15
|
-
name = "watir/#{__FILE__}_#{cnt}.html".sub('.rb','')
|
16
|
-
ausgabe = File.open(name, "w+")
|
17
|
-
ausgabe.write(b.html)
|
18
|
-
$cnt += 1 if $cnt.to_i != 0
|
19
|
-
|
20
|
-
end
|
21
|
-
Swiss_reg_URL = 'https://www.swissreg.ch'
|
22
|
-
client = Selenium::WebDriver::Remote::Http::Default.new
|
23
|
-
browser = Watir::Browser.new :firefox #, :http_client => client
|
24
|
-
# browser = Watir::Browser.new :chrome #, :http_client => client
|
25
|
-
browser.goto Swiss_reg_URL
|
26
|
-
#browser = Watir::Browser.start "https://www.swissreg.ch"
|
27
|
-
saveStep(browser, 11)
|
28
|
-
browser.link(:id, "id_swissreg_sub_nav_ipiNavigation_item0").click
|
29
|
-
saveStep(browser, 12 )
|
30
|
-
browser.link(:id, "id_swissreg_sub_nav_ipiNavigation_item0_item3").click
|
31
|
-
saveStep(browser, 13 )
|
32
|
-
browser.text_field(:id, "id_swissreg:mainContent:id_txf_appDate").set("1.10.2011-5.10.2011")
|
33
|
-
saveStep(browser, 14 )
|
34
|
-
browser.button(:value,"suchen").click
|
35
|
-
saveStep(browser, 15)
|
36
|
-
aus = browser.text
|
37
|
-
ausgabe=File.open('watir/liste.txt','w+')
|
38
|
-
ausgabe.puts aus
|
39
|
-
ausgabe.close
|
40
|
-
browser.link(:id, "id_swissreg:mainContent:data:2:tm_no_detail:id_detail").click# puts browser.text
|
41
|
-
browser.images.each do |x|
|
42
|
-
idx += 1
|
43
|
-
# apparently the string accepted by the string method will not allow variable substitution
|
44
|
-
location = 'img_' + idx.to_s + '.png'
|
45
|
-
x.save(location)
|
46
|
-
end
|
47
|
-
puts browser.url
|
48
|
-
pp browser.windows.each{ |w|
|
49
|
-
pp w.url
|
50
|
-
# saveStep(w)
|
51
|
-
}
|
52
|
-
# window2 = Watir::Browser.attach(:url, "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr30.jsp") stackLevel too deep
|
53
|
-
#window2 = Selenium::WebDriver::Firefox.attach(:url, "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr30.jsp")
|
54
|
-
#saveStep(window2)
|
55
|
-
#aus = window2.text
|
56
|
-
ausgabe=File.open('watir/detail.txt','w+')
|
57
|
-
ausgabe.puts aus
|
58
|
-
ausgabe.close
|
data/swissreg.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
require 'rubygems' if /^1\.8/.match(RUBY_VERSION)
|
4
|
-
require 'mechanize'
|
5
|
-
require 'prettyprint'
|
6
|
-
|
7
|
-
def writeResponse(filename)
|
8
|
-
ausgabe = File.open(filename, 'w+')
|
9
|
-
ausgabe.puts @agent.page.body
|
10
|
-
ausgabe.close
|
11
|
-
end
|
12
|
-
|
13
|
-
@agent = Mechanize.new { |agent|
|
14
|
-
agent.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0'
|
15
|
-
agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
16
|
-
}
|
17
|
-
|
18
|
-
@agent.get_file 'https://www.swissreg.ch/srclient/faces/jsp/start.jsp'
|
19
|
-
writeResponse("log_#{__LINE__}.html") # complains about missing
|
20
|
-
@agent.page.links[3].click
|
21
|
-
writeResponse("log_#{__LINE__}.html")
|
22
|
-
@state = @agent.page.form["javax.faces.ViewState"]
|
23
|
-
data = [
|
24
|
-
["autoScroll", "0,0"],
|
25
|
-
["id_swissreg:_link_hidden_", ""],
|
26
|
-
["id_swissreg_SUBMIT", "1"],
|
27
|
-
["id_swissreg:_idcl", "id_swissreg_sub_nav_ipiNavigation_item0"],
|
28
|
-
["javax.faces.ViewState", @state],
|
29
|
-
]
|
30
|
-
@agent.page.form['id_swissreg:_idcl'] = 'id_swissreg_sub_nav_ipiNavigation_item0'
|
31
|
-
@agent.page.forms.first.submit
|
32
|
-
writeResponse("log_#{__LINE__}.html")
|
33
|
-
data = [
|
34
|
-
["autoScroll", "0,0"],
|
35
|
-
["id_swissreg:_link_hidden_", ""],
|
36
|
-
["id_swissreg_SUBMIT", "1"],
|
37
|
-
["id_swissreg:_idcl", "id_swissreg_sub_nav_ipiNavigation_item0_item3"],
|
38
|
-
["javax.faces.ViewState", @state],
|
39
|
-
]
|
40
|
-
@agent.page.form['id_swissreg:_idcl'] = 'id_swissreg_sub_nav_ipiNavigation_item0_item3'
|
41
|
-
@agent.page.forms.first.submit
|
42
|
-
writeResponse("log_#{__LINE__}.html")
|
43
|
-
data = [
|
44
|
-
["autoScroll", "0,829"],
|
45
|
-
["id_swissreg:_link_hidden_", ""],
|
46
|
-
["id_swissreg:mainContent:id_ckbTMState", "1"], # "Hängige Gesuche 1
|
47
|
-
["id_swissreg:mainContent:id_ckbTMState", "3"], # "Hängige Gesuche 1
|
48
|
-
["id_swissreg:mainContent:id_txf_tm_no", ""],# Marken Nr
|
49
|
-
["id_swissreg:mainContent:id_txf_app_no", ""], # Gesuch Nr.
|
50
|
-
["id_swissreg:mainContent:id_txf_tm_text", "asp*"],
|
51
|
-
["id_swissreg:mainContent:id_txf_applicant", ""], # Inhaber/in
|
52
|
-
["id_swissreg:mainContent:id_txf_agent", ""], # Vertreter/in
|
53
|
-
["id_swissreg:mainContent:id_txf_licensee", ""], # Lizenznehmer
|
54
|
-
["id_swissreg:mainContent:id_txf_nizza_class", ""], # Nizza Klassifikation Nr.
|
55
|
-
["id_swissreg:mainContent:id_txf_appDate", "01.01.2000-31.12.2012"] ,
|
56
|
-
["id_swissreg:mainContent:id_txf_expiryDate", ""], # Ablauf Schutzfrist
|
57
|
-
["id_swissreg:mainContent:id_cbxTMTypeGrp", "_ALL"], # Markenart
|
58
|
-
["id_swissreg:mainContent:id_cbxTMForm", "_ALL"], # Markentyp
|
59
|
-
["id_swissreg:mainContent:id_cbxTMColorClaim", "_ALL"], # Farbanspruch
|
60
|
-
["id_swissreg:mainContent:id_txf_pub_date", ""], # Publikationsdatum
|
61
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", '1'],
|
62
|
-
["id_swissreg:mainContent:id_ckbTMPubReason", '2'],
|
63
|
-
["id_swissreg:mainContent:id_cbxFormatChoice", "1"],
|
64
|
-
["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_tm_text"],
|
65
|
-
["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_applicant"],
|
66
|
-
["id_swissreg:mainContent:id_ckbTMChoice", "tm_lbl_country"],
|
67
|
-
["id_swissreg:mainContent:id_cbxHitsPerPage", 250], # Treffer pro Seite
|
68
|
-
["id_swissreg:mainContent:sub_fieldset:id_submit", "suchen"],
|
69
|
-
["id_swissreg_SUBMIT", "1"],
|
70
|
-
["id_swissreg:_idcl", ""],
|
71
|
-
["id_swissreg:_link_hidden_", ""],
|
72
|
-
["javax.faces.ViewState", @state],
|
73
|
-
]
|
74
|
-
@agent.post('https://www.swissreg.ch/srclient/faces/jsp/trademark/sr3.jsp', data)
|
75
|
-
writeResponse("log_#{__LINE__}.html")
|