How to extract data from text columns - ruby

I have two addresses side-by-side in a multi-line string:
Adresse de prise en charge : Adresse d'arrivée :
rue des capucines rue des tilleuls
92210 Saint Cloud 67000 Strasbourg
Tél.: Tél.:
I need to extract the addresses on the left and right with a regexp, and assign them to variables. I need to match:
address1: "rue des capucines 92210 Saint Cloud"
address2: "rue des tilleuls 67000 Strasbourg"
I thought of separating them with spaces, but I cant find any regexp to count the spaces. I tried:
en\s*charge\s*:\s*((.|\n)*)\s*
and similar, but that gives me both addresses, and is not what I'm looking for. Any help will be deeply appreciated.

I'd do something like this:
str = <<EOT
Adresse de prise en charge : Adresse d'arrivée :
rue des capucines rue des tilleuls
92210 Saint Cloud 67000 Strasbourg
Tél.: Tél.:
EOT
left_addr = []
right_addr = []
lines = str.squeeze("\n").gsub(':', '').lines.map(&:strip) # => ["Adresse de prise en charge Adresse d'arrivée", "rue des capucines rue des tilleuls", "92210 Saint Cloud 67000 Strasbourg", "Tél. Tél."]
center_line_pos = lines.max.length / 2 # => 35
lines.each do |l|
left_addr << l[0 .. (center_line_pos - 1)].strip
right_addr << l[center_line_pos .. -1].strip
end
At this point left_addr and right_addr look like:
left_addr # => ["Adresse de prise en charge", "rue des capucines", "92210 Saint Cloud", "Tél."]
right_addr # => ["Adresse d'arrivée", "rue des tilleuls", "67000 Strasbourg", "Tél."]
And here's what they contain:
puts left_addr
puts '------'
puts right_addr
# >> Adresse de prise en charge
# >> rue des capucines
# >> 92210 Saint Cloud
# >> Tél.
# >> ------
# >> Adresse d'arrivée
# >> rue des tilleuls
# >> 67000 Strasbourg
# >> Tél.
If you need the results all in one line without the 'Tel:':
puts left_addr[0..-2].join(' ').squeeze(' ')
puts '------'
puts right_addr[0..-2].join(' ').squeeze(' ')
# >> Adresse de prise en charge rue des capucines 92210 Saint Cloud
# >> ------
# >> Adresse d'arrivée rue des tilleuls 67000 Strasbourg
Here's a breakdown of what is going on:
str.squeeze("\n") # => " Adresse de prise en charge : Adresse d'arrivée :\n rue des capucines rue des tilleuls\n 92210 Saint Cloud 67000 Strasbourg\n Tél.: Tél.:\n"
.gsub(':', '') # => " Adresse de prise en charge Adresse d'arrivée \n rue des capucines rue des tilleuls\n 92210 Saint Cloud 67000 Strasbourg\n Tél. Tél.\n"
.lines # => [" Adresse de prise en charge Adresse d'arrivée \n", " rue des capucines rue des tilleuls\n", " 92210 Saint Cloud 67000 Strasbourg\n", " Tél. Tél.\n"]
.map(&:strip) # => ["Adresse de prise en charge Adresse d'arrivée", "rue des capucines rue des tilleuls", "92210 Saint Cloud 67000 Strasbourg", "Tél. Tél."]

Assuming that each address section in each line is indented as much as or further than the corresponding "Adresse" in the first line, the following can extract not only two addresses aligned sidewards, but n addresses in general.
lines = string.split(/#{$/}+/)
# => [
# => "Adresse de prise en charge : Adresse d'arrivée :",
# => " rue des capucines rue des tilleuls",
# => " 92210 Saint Cloud 67000 Strasbourg",
# => " Tél.: Tél.:"
# => ]
break_points = []
lines.first.scan(/\bAdresse\b/){break_points.push($~.begin(0))}
ranges = break_points.push(0).each_cons(2).map{|s, e| s..(e - 1)}
# => [0..53, 54..-1]
address1, address2 =
lines[1..-2]
.map{|s| ranges.map{|r| s[r]}}
.transpose
.map{|a| a.join(" ").strip.squeeze(" ")}
# => [
# => "rue des capucines 92210 Saint Cloud",
# => "rue des tilleuls 67000 Strasbourg"
# => ]

str =
" Adresse de prise en charge : Adresse d'arrivée :
rue des capucines rue des tilleuls
92210 Saint Cloud 67000 Strasbourg
Tél.: Tél.:"
adr_prise, adr_arr = str.lines[3].strip.split(/ {2,}/) #split on 2+ spaces
code_prise, cite_prise, code_arr, cite_arr = str.lines[6].strip.split(/ {2,}/)

Assumptions
I have assumed that the first and last lines are not wanted and the street names are separated by at least two spaces, and the same for the postal code/city strings. This permits the street name (and postal code/city pair) for "prise en charge" to end below "Adresse d'arrivée :".
Code
def parse_text(text)
text.split(/\n+\s+/)[1..-2].
map { |s| s.gsub(/\d+\K\s+/,' ').split(/\s{2,}/) }.
transpose.
map { |a| a.join(' ') }
end
Examples
Example 1
text = <<BITTER_END
Adresse de prise en charge : Adresse d'arrivée :
rue des capucines rue des tilleuls
92210 Saint Cloud 67000 Strasbourg
Tél.: Tél.:
BITTER_END
parse_text(text)
#=> ["rue des capucines 9210 Saint Cloud",
# "rue des tileuls 670 Strasbourg"]
Example 2
text = <<_
Adresse 1 : Adresse 2 : Adresse 3 :
rue nom le plus long du monde par un mile rue gargouilles rue des tilleuls
92210 Saint Cloud 31400 Nice 67000 Strasbourg
France France France
Tél.: Tél.: Tél.:
_
parse_text(text)
#=> ["rue nom le plus long du monde par un mile 92210 Saint Cloud France",
# "rue gargouilles 31400 Nice France",
# "rue des tilleuls 67000 Strasbourg France"]
Explanation
The steps for text given in the question:
Split into lines, removing blank lines and leading spaces:
a1 = text.split(/\n+\s+/)
#=> ["Adresse de prise en charge : Adresse d'arrivée :",
# "rue des capucines rue des tilleuls",
# "92210 Saint Cloud 67000 Strasbourg",
# "Tél.: Tél.:\n"]
Remove first and last lines:
a2 = a1[1..-2]
#=> ["rue des capucines rue des tilleuls",
# "92210 Saint Cloud 67000 Strasbourg"]
Remove extra spaces between the postal codes and cities and split each line on two or more spaces:
r = /
\d+ # match one or more digits
\K # forget everything matched so far
\s+ # match one of more spaces
/x # extended/free-spacing regex definition mode
a3 = a2.map { |s| s.gsub(/\d+\K\s+/,' ').split(/\s{2,}/) }
#=> [["rue des capucines", "rue des tilleuls"],
# ["92210 Saint Cloud", "67000 Strasbourg"]]
Group by column:
a4 = a3.transpose
#=> [["rue des capucines", "92210 Saint Cloud"],
# ["rue des tilleuls", "67000 Strasbourg"]]
Join strings:
a4.map { |a| a.join(' ') }
#=> ["rue des capucines 92210 Saint Cloud",
# "rue des tilleuls 67000 Strasbourg"]

Inspired by #steenslag's very pragmatic answer, here's a pretty dense one-liner just for fun.
# Assume the input data is in the variable `text`
left_addr, right_addr = text.lines.values_at(3, 6).map do |line|
line.scan(/(?:\d+ +)?\S+(?: \S+)*/)
.map {|part| part.squeeze(' ') }
end
.transpose
.map {|addr| addr.join(' ') }
puts left_addr
# => rue des capucines 92210 Saint Cloud
puts right_addr
# => rue des tilleuls 67000 Strasbourg
Like #steenslag's answer, this assumes that the desired data is always on lines 3 and 6. It also assumes that on line 6 both columns will have a postal code and city and that the postal code will always start with a digit.
Because it's a pretty dense one-liner and because it makes a lot of assumptions, I don't think this is the best answer and I'm marking it Community Wiki.
If I have time I'll come back and unpack this later.

Assuming that the "center line position" is known, this would work:
left_lines, right_lines = str.scan(/^(.{50})(.*)$/).transpose
The regular expression captures 50 characters at the beginning of each line plus the remaining characters until the line's end.
scan returns a nested array: (I'm using placeholders because the actual lines are too long)
[
['1st left line', '1st right line'],
['2nd left line', '2nd right line'],
...
]
transpose converts it to:
[
['1st left line', '2nd left line', ...], # <- assigned to left_lines
['1st right line', '2nd right line', ...] # <- assigned to right_lines
]
The lines (excluding the first and last line) have to be joined and spaces have to be removed: (see strip and squeeze)
left_lines[1..-2].join(' ').strip.squeeze(' ')
#=> "rue des capucines 92210 Saint Cloud"
Same for right_lines:
right_lines[1..-2].join(' ').strip.squeeze(' ')
#=> "rue des tilleuls 67000 Strasbourg"

Related

Recaptcha nieuwe domeinnaam wijzigen

ik heb mijn domeinnaam vervangen door een nieuwe domeinnaam. bij het aanmaken van een site key sleutel heb ik de fout gemaakt in de nieuwe domeinnaam nl. skgent.be in plaats van skggent.be Nu werkt de sleutel uiteraard niet maar ik kan die koppeling aan de verkeerde domeinnaam niet verwijderen?

HMTLUnit how to get IMG url in javascript?

For HTMLunit prof here, can you tell if it's possible to get each url present in a javascript code.
For example, in this code, i'd like to get each ".jpg" url :
I mean, alle images in "photos" variable.
Thank you for your help
<script ngappstate>var ngAppState = {"advertising":{"triggerImbvpjs":false},"authentication":{"isBusy":false},"property":{"estate":{"id":8345497,"publisherId":785672,"pubDate":"2019-09-17T10:08:13.000+02:00","photos":["https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.jpg?cache=2019091009047","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.jpg?cache=2019091009097","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.jpg?cache=2019091009330","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.jpg?cache=2019091009330","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.jpg?cache=2019091009657","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.jpg?cache=2019091009737","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.jpg?cache=2019091009843","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.jpg?cache=2019091009953","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.jpg?cache=2019091009017","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.jpg?cache=2019091009093","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.jpg?cache=2019091009233","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.jpg?cache=2019091009453","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.jpg?cache=2019091009560","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.jpg?cache=2019091009873","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.jpg?cache=2019091009907"],"picturesResized":[{"lastModificationDate":"2019-09-17T10:09:19.080+02:00","ordering":1,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.jpg?cache=2019091009047","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_1.jpg?cache=2019091009080","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.gif?cache=2019091009080","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.110+02:00","ordering":2,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.jpg?cache=2019091009097","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_2.jpg?cache=2019091009110","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.gif?cache=2019091009110","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.330+02:00","ordering":3,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.jpg?cache=2019091009330","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_3.jpg?cache=2019091009330","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.gif?cache=2019091009347","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.347+02:00","ordering":4,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.jpg?cache=2019091009330","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_4.jpg?cache=2019091009347","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.gif?cache=2019091009423","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.673+02:00","ordering":5,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.jpg?cache=2019091009657","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_5.jpg?cache=2019091009673","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.gif?cache=2019091009673","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.737+02:00","ordering":6,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.jpg?cache=2019091009737","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_6.jpg?cache=2019091009737","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.gif?cache=2019091009750","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.843+02:00","ordering":7,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.jpg?cache=2019091009843","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_7.jpg?cache=2019091009843","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.gif?cache=2019091009860","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.970+02:00","ordering":8,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.jpg?cache=2019091009953","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_8.jpg?cache=2019091009970","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.gif?cache=2019091009983","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.030+02:00","ordering":9,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.jpg?cache=2019091009017","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_9.jpg?cache=2019091009030","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.gif?cache=2019091009047","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.110+02:00","ordering":11,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.jpg?cache=2019091009093","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_A.jpg?cache=2019091009110","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.gif?cache=2019091009110","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.250+02:00","ordering":12,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.jpg?cache=2019091009233","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_B.jpg?cache=2019091009250","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.gif?cache=2019091009453","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":13,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.jpg?cache=2019091009453","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_C.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.gif?cache=2019091009547","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":14,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_D.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.gif?cache=2019091009657","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":15,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_E.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":16,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.jpg?cache=2019091009560","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_F.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":17,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_G.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":18,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_H.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":19,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_I.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":20,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_J.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.907+02:00","ordering":21,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.jpg?cache=2019091009873","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_K.jpg?cache=2019091009907","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.907+02:00","ordering":22,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.jpg?cache=2019091009907","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_L.jpg?cache=2019091009907","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.gif?cache=2019091009920","pictureOrientation":"LANDSCAPE"}],"flags":{"new":true,"defaultOrderingScore":1,"priceOrderingScore":279000,"dateOrderingScore":"2019-09-17T10:08:13.657+02:00","pricem2orderScore":0,"adQualityScore":90.87},"adType":"M","energy":{"energyConsumption":495,"yearlyTheoreticalTotalEnergyConsumption":109187,"EPCScore":"F","CO2emission":null,"EPCreferenceNumber":"20190811002958","Heating":"Gas","doubleGlazing":true,"epcreferenceNumber":"20190811002958"},"media":[{"type":"VIRTUAL_TOUR","content":{"value":"https://my.matterport.com/show/?m=jXVimgXaXwY&lang=fr&help=2&lp=1&hl=0&ts=1&st=5000&guides=0&qs=1' f"}}],"mainType":"HOUSE","subtype":"HOUSE","geographical":{"geo":{"latitude":50.4037765,"longitude":4.395336},"geoPoint":{"latitude":50.4037765,"longitude":4.395336},"hasSeaView":false,"postal":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Montigny-le-Tilleul","postalcode":"6110","street":"Rue de Cartier","number":"56","box":"","buildingName":"","region":"WALLONIE"},"postalAddr":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Montigny-le-Tilleul","postalcode":"6110","street":"Rue de Cartier","number":"56","box":"","buildingName":"","region":"WALLONIE"}},"buyRent":"BUY","transactionSubtype":"BUY_REGULAR","activationStatus":"CODE_STATUS_ACTIVATED","description":{"title":"Magnifique maison de maitre 4 façades entièrement rénovée, 4","description":"!!!Rue de Cartier 56 Commune de Marchienne - au - Pont!!! https://www.youtube.com/watch?v=k_pd8XSxgoE ou n'hésitez pas à cliquer sur l'onglet MEDIA (sur la première photo) pour une visite virtuelle interactive. VISITES ET RENSEIGNEMENTS AU 0487 34 34 83 - Magnifique maison de maitre 4 façades entièrement rénovée, 4 chambres avec jardin. Comprenant caves, hall d'entrée, living, cuisine, bureau, salle de bains avec wc, double vasques, baignoire, douche italienne. 1°: hall de nuit, deux chambres. Au 2°: hall de nuit, deux chambres. Chauffage central au gaz, châssis TV PVC, plancher béton à tous les niveaux, cuisine Ducati prix d'achat 56.000€, alarme, adoucisseur d'eau. FAIRE OFFRE A PARTIR DE 279.000€. DESCRIPTIF COMPLET SUR LE","moreInfo":"WWW.LOPPORTUNITE.BE A TITRE INFORMATIF ET NON CONTRACTUEL."},"general":{"netFloorArea":220,"frontageNumber":4,"buildingCondition":"JUST_RENOVATED","availability":""},"interior":{"bedrooms":4,"bathroomNumber":1,"toiletsNumber":1,"kitchenSetup":"Installed","cellarProperty":true},"buildingRegulation":{"planningPermissionObtained":"NOT_SPECIFIED","asBuiltPlan":"NO","subdivisionPermit":"NOT_SPECIFIED","possiblePriorityPurchaseRight":"NOT_SPECIFIED","proceedingsForBreachOfPlanningRegulations":"NOT_SPECIFIED","floodZoneInfo":null},"financial":{"vatProfile":"VAT_INCLUDED","salePrice":279000,"cadastralIncome":803,"priceBasedOn":false,"isMinimumBid":false,"isPriceBased":false},"soldInfo":{"sold":false,"soldLabel":"NO_LABEL"},"contactInfo":{"phone":"+3271799549","email":"lopportunite#omniwebsites.be","mobile":"","idclient":785672,"clientType":"AGE","title":"L' OPPORTUNITE","location":{"geo":{"latitude":50.4115438,"longitude":4.381455},"geoPoint":{"latitude":50.4115438,"longitude":4.381455},"postal":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Monceau-sur-sambre","postalcode":"6031","street":"Rue des Combattants 37","number":"","box":"","region":"WALLONIE"},"postalAddr":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Monceau-sur-sambre","postalcode":"6031","street":"Rue des Combattants 37","number":"","box":"","region":"WALLONIE"}},"logo":"https://static.immoweb.be/logos/785672.gif?cache=2017061204440","www":"http://www.lopportunite.be","ipiNo":"503906","referenceWithinSoftware":"2655","referenceWithinAgency":"2655 - 868","responsible":""},"land":{"surfaceAreaOfPlot":230}},"publishers":[{"id":785672,"ipiNo":"503906","geoPoint":{"latitude":50.4115438,"longitude":4.381455},"name":"L' OPPORTUNITE","logoUri":"https://static.immoweb.be/logos/785672.gif?cache=2017061204440","email":"lopportunite#omniwebsites.be","phones":["+3271799549"],"address":"Rue des Combattants 37","zip":6031,"locality":"Monceau-sur-sambre","description":{"text":"Nous vendons rapidement votre maison, appartement, immeuble de rapport, terrain,… et ce au meilleur prix.\r\n\r\n- ESTIMATION DE VOTRE BIEN\r\n- SERVICE PERSONNALISE A NOTRE CLIENTELE\r\n- MISSION DE VENTE CLAIRE ET PRECISE\r\n- PUBLICITE CIBLEE, VISITES ORGANISEES","language":"fr"},"timetable":{},"contactHours":"MT","contactHoursGsm":"MT","emails":[{"contactInformation":"lopportunite#omniwebsites.be","usage":"DEFAULT"}],"landLines":[{"contactInformation":"+3271799549","usage":"DEFAULT"}],"faxMachines":[{"contactInformation":"+3271315405","usage":"DEFAULT"}],"country":"be"}],"media":null,"status":1}};</script>
You wouldnt do something like that with htmlunit. Instead use Regular Expressions to search for those links. You can use this regular expression for the task: (http([a-zA-Z\/:\.0-9_]*)?.jpg). The example looks like this:
var reg= /(http([a-zA-Z\/:\.0-9_]*)?.jpg)/g;
var ngAppState = {"advertising":{"triggerImbvpjs":false},"authentication":{"isBusy":false},"property":{"estate":{"id":8345497,"publisherId":785672,"pubDate":"2019-09-17T10:08:13.000+02:00","photos":["https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.jpg?cache=2019091009047","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.jpg?cache=2019091009097","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.jpg?cache=2019091009330","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.jpg?cache=2019091009330","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.jpg?cache=2019091009657","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.jpg?cache=2019091009737","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.jpg?cache=2019091009843","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.jpg?cache=2019091009953","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.jpg?cache=2019091009017","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.jpg?cache=2019091009093","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.jpg?cache=2019091009233","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.jpg?cache=2019091009453","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.jpg?cache=2019091009560","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.jpg?cache=2019091009873","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.jpg?cache=2019091009907"],"picturesResized":[{"lastModificationDate":"2019-09-17T10:09:19.080+02:00","ordering":1,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.jpg?cache=2019091009047","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_1.jpg?cache=2019091009080","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.gif?cache=2019091009080","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.110+02:00","ordering":2,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.jpg?cache=2019091009097","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_2.jpg?cache=2019091009110","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.gif?cache=2019091009110","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.330+02:00","ordering":3,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.jpg?cache=2019091009330","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_3.jpg?cache=2019091009330","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.gif?cache=2019091009347","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.347+02:00","ordering":4,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.jpg?cache=2019091009330","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_4.jpg?cache=2019091009347","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.gif?cache=2019091009423","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.673+02:00","ordering":5,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.jpg?cache=2019091009657","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_5.jpg?cache=2019091009673","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.gif?cache=2019091009673","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.737+02:00","ordering":6,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.jpg?cache=2019091009737","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_6.jpg?cache=2019091009737","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.gif?cache=2019091009750","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.843+02:00","ordering":7,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.jpg?cache=2019091009843","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_7.jpg?cache=2019091009843","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.gif?cache=2019091009860","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.970+02:00","ordering":8,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.jpg?cache=2019091009953","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_8.jpg?cache=2019091009970","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.gif?cache=2019091009983","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.030+02:00","ordering":9,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.jpg?cache=2019091009017","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_9.jpg?cache=2019091009030","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.gif?cache=2019091009047","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.110+02:00","ordering":11,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.jpg?cache=2019091009093","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_A.jpg?cache=2019091009110","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.gif?cache=2019091009110","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.250+02:00","ordering":12,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.jpg?cache=2019091009233","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_B.jpg?cache=2019091009250","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.gif?cache=2019091009453","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":13,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.jpg?cache=2019091009453","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_C.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.gif?cache=2019091009547","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":14,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_D.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.gif?cache=2019091009657","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":15,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_E.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":16,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.jpg?cache=2019091009560","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_F.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":17,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_G.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":18,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_H.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":19,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_I.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":20,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_J.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.907+02:00","ordering":21,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.jpg?cache=2019091009873","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_K.jpg?cache=2019091009907","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.907+02:00","ordering":22,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.jpg?cache=2019091009907","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_L.jpg?cache=2019091009907","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.gif?cache=2019091009920","pictureOrientation":"LANDSCAPE"}],"flags":{"new":true,"defaultOrderingScore":1,"priceOrderingScore":279000,"dateOrderingScore":"2019-09-17T10:08:13.657+02:00","pricem2orderScore":0,"adQualityScore":90.87},"adType":"M","energy":{"energyConsumption":495,"yearlyTheoreticalTotalEnergyConsumption":109187,"EPCScore":"F","CO2emission":null,"EPCreferenceNumber":"20190811002958","Heating":"Gas","doubleGlazing":true,"epcreferenceNumber":"20190811002958"},"media":[{"type":"VIRTUAL_TOUR","content":{"value":"https://my.matterport.com/show/?m=jXVimgXaXwY&lang=fr&help=2&lp=1&hl=0&ts=1&st=5000&guides=0&qs=1' f"}}],"mainType":"HOUSE","subtype":"HOUSE","geographical":{"geo":{"latitude":50.4037765,"longitude":4.395336},"geoPoint":{"latitude":50.4037765,"longitude":4.395336},"hasSeaView":false,"postal":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Montigny-le-Tilleul","postalcode":"6110","street":"Rue de Cartier","number":"56","box":"","buildingName":"","region":"WALLONIE"},"postalAddr":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Montigny-le-Tilleul","postalcode":"6110","street":"Rue de Cartier","number":"56","box":"","buildingName":"","region":"WALLONIE"}},"buyRent":"BUY","transactionSubtype":"BUY_REGULAR","activationStatus":"CODE_STATUS_ACTIVATED","description":{"title":"Magnifique maison de maitre 4 façades entièrement rénovée, 4","description":"!!!Rue de Cartier 56 Commune de Marchienne - au - Pont!!! https://www.youtube.com/watch?v=k_pd8XSxgoE ou n'hésitez pas à cliquer sur l'onglet MEDIA (sur la première photo) pour une visite virtuelle interactive. VISITES ET RENSEIGNEMENTS AU 0487 34 34 83 - Magnifique maison de maitre 4 façades entièrement rénovée, 4 chambres avec jardin. Comprenant caves, hall d'entrée, living, cuisine, bureau, salle de bains avec wc, double vasques, baignoire, douche italienne. 1°: hall de nuit, deux chambres. Au 2°: hall de nuit, deux chambres. Chauffage central au gaz, châssis TV PVC, plancher béton à tous les niveaux, cuisine Ducati prix d'achat 56.000€, alarme, adoucisseur d'eau. FAIRE OFFRE A PARTIR DE 279.000€. DESCRIPTIF COMPLET SUR LE","moreInfo":"WWW.LOPPORTUNITE.BE A TITRE INFORMATIF ET NON CONTRACTUEL."},"general":{"netFloorArea":220,"frontageNumber":4,"buildingCondition":"JUST_RENOVATED","availability":""},"interior":{"bedrooms":4,"bathroomNumber":1,"toiletsNumber":1,"kitchenSetup":"Installed","cellarProperty":true},"buildingRegulation":{"planningPermissionObtained":"NOT_SPECIFIED","asBuiltPlan":"NO","subdivisionPermit":"NOT_SPECIFIED","possiblePriorityPurchaseRight":"NOT_SPECIFIED","proceedingsForBreachOfPlanningRegulations":"NOT_SPECIFIED","floodZoneInfo":null},"financial":{"vatProfile":"VAT_INCLUDED","salePrice":279000,"cadastralIncome":803,"priceBasedOn":false,"isMinimumBid":false,"isPriceBased":false},"soldInfo":{"sold":false,"soldLabel":"NO_LABEL"},"contactInfo":{"phone":"+3271799549","email":"lopportunite#omniwebsites.be","mobile":"","idclient":785672,"clientType":"AGE","title":"L' OPPORTUNITE","location":{"geo":{"latitude":50.4115438,"longitude":4.381455},"geoPoint":{"latitude":50.4115438,"longitude":4.381455},"postal":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Monceau-sur-sambre","postalcode":"6031","street":"Rue des Combattants 37","number":"","box":"","region":"WALLONIE"},"postalAddr":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Monceau-sur-sambre","postalcode":"6031","street":"Rue des Combattants 37","number":"","box":"","region":"WALLONIE"}},"logo":"https://static.immoweb.be/logos/785672.gif?cache=2017061204440","www":"http://www.lopportunite.be","ipiNo":"503906","referenceWithinSoftware":"2655","referenceWithinAgency":"2655 - 868","responsible":""},"land":{"surfaceAreaOfPlot":230}},"publishers":[{"id":785672,"ipiNo":"503906","geoPoint":{"latitude":50.4115438,"longitude":4.381455},"name":"L' OPPORTUNITE","logoUri":"https://static.immoweb.be/logos/785672.gif?cache=2017061204440","email":"lopportunite#omniwebsites.be","phones":["+3271799549"],"address":"Rue des Combattants 37","zip":6031,"locality":"Monceau-sur-sambre","description":{"text":"Nous vendons rapidement votre maison, appartement, immeuble de rapport, terrain,… et ce au meilleur prix.\r\n\r\n- ESTIMATION DE VOTRE BIEN\r\n- SERVICE PERSONNALISE A NOTRE CLIENTELE\r\n- MISSION DE VENTE CLAIRE ET PRECISE\r\n- PUBLICITE CIBLEE, VISITES ORGANISEES","language":"fr"},"timetable":{},"contactHours":"MT","contactHoursGsm":"MT","emails":[{"contactInformation":"lopportunite#omniwebsites.be","usage":"DEFAULT"}],"landLines":[{"contactInformation":"+3271799549","usage":"DEFAULT"}],"faxMachines":[{"contactInformation":"+3271315405","usage":"DEFAULT"}],"country":"be"}],"media":null,"status":1}};
var text = JSON.stringify(ngAppState);
while((result = reg.exec(text)) !== null) {
console.log(result[0]);
}

Explanation of error using "color" in a batch script

In order to set the color of a batch script's console/terminal, color can be used. E.g. color 70. However, in order to reset the color of a the console, color without any arguments/values can be used. What is causing confusion for me is why it only works inside the command prompt or a called script but not a script started specifically with cmd /c. It fails and returns an errorcode of 1. Is there some legacy reason for this or is it a bug in Windows?
cmd /c color || echo foobar
Output: foobar
Expected output:
cmd /c color 70 || echo foobar
Output:
Expected output:
call color || echo foobar
Output:
Expected output:
To have no error, try to put the default color, as you said,
the color of a the console
That means the default color, I gess, so put color 07, to switch to color black-light grey.
For more info for colors in a .bat file create a .bat file and put in it color h, only this, save it and run it. It will give you all the info about colors.
If you are not able to do this, here is what it will show you. (Sorry, it's in french, but I gess you can understand)
Change les couleurs par défaut du premier et de l'arrière plan de la console.
COLOR [attr]
attr Spécifie les attributs de couleurs de l'apparence de la console
Les attributs de couleurs sont spécifiés par DEUX chiffres hexadécimaux -- le
premier correspond à l'arrière plan, le second au premier plan. Chaque chiffre
peut prendre n'importe quelle de ces valeurs :
0 = Noir 8 = Gris
1 = Bleu foncé 9 = Bleu clair
2 = Vert A = Vert clair
3 = Bleu-gris B = Cyan
4 = Marron C = Rouge
5 = Pourpre D = Rose
6 = Kaki E = Jaune
7 = Gris clair F = Blanc
Si aucun argument n'est donné, cette commande restaure les couleurs
sélectionnées au moment où CMD.EXE a été ouvert. Cette valeur vient soit de la
fenêtre de la console, du commutateur en ligne de commande /T, ou de la valeur
DefaultColor du registre.
Appuyez sur une touche pour continuer...
Again, sorry that is in french
Kalolol

termvector counting keywords in Elasticsearch

I am using elasticsearch 1.5.2.
I want to get the number of time that every keyword is repeated on a stored products in my index.
keywords are : sauces, crèmes, gâteaux.
these are my products:
POST test/prod
{
"titre": "product 1",
"catégorie": "Epicerie",
"informations": "Sauces, potages, crèmes & gâteaux. / Composé exclusivement d'amidon de maïs, il vous permet d'alléger vos gâteaux et crêpes ou bien d'épaissir vos sauces, soupes et crèmes. Il rend vos desserts onctueux et légers : il suffit simplement de remplacer la moitié de votre farine par la fécule de maïs. // Poids net : 0,400 kg // Veuillez contacter notre responsable de mise en marché : Distribué par Système U - BP 30159 - 94533 Rungis cedex"
}
POST test/prod
{
"titre": "product 2",
"catégorie": "Fruits",
"informations": "A conserver dans un endoit frais et sec. Idée recette: Madeleines fourrées au chocolat Ingrédients (pour une vingtaine de madeleines) : 100g de farine, 90g fécule de maïs,1 sachet de levure, 3 oeufs,125g de sucre,190g de beurre,1cuillère à soupe d'eau de fleur d'oranger, 1 vingtaine de carrés de chocolat Préparation : Mélangez la farine, la fécule et la levure. Ajoutez le sucre et les oeufs battus. Faites fondre le beurre à feu doux et incorporer le au précédent mélange. Mélangez bien et laissez reposer la pâte une heure au réfrigérateur. Préchauffez le four à 220°C. Beurrez les moules à madeleine, garnissez les moules de moitié, ajoutez au centre un petit carré de chocolat et recouvrez de l'appareil à madeleine. Enfournez pour 5 minutes puis baissez le four à 180°C et poursuivez la cuisson 5 minutes. Sortez les madeleines, laissez-les tiédir et démoulez-les."
}
I want to get a result in order desc like this for example:
product 1:
sauces repeated :9
crèmes repeated :8
gâteaux repeated: 2
product 2:
sauces repeated :8
crèmes repeated :6
gâteaux repeated: 4
I used termvector in only one field, however I want to get the result from all document. It was like this:
POST test/prod/1/_termvector
{
"fields" : ["informations"],
"offsets" : true,
"payloads" : true,
"positions" : true,
"term_statistics" : true,
"field_statistics" : true
}
But I get as a result a very long list which contains all words in this field. I want only as a result my 3 keywords.

AWK: Compare two files and calculate a percentage based on differences

I have two files as these..
What I need is to count the number of times each ID appears on each file and calculate the difference to obtain percentage of success. Furthermore, when the third column of the first file contains the word NONE and the same column of the second file contains a number, indicate that has been obtained category for that ID.
File 1:
ID;Coments;Category
2;es un anuncio interesante que le puede servir para alguien;321
3;es un anuncio de un banco que quiere presentarse como una compañía;NONE
4;es un anuncio de un banco que ofrece prestamos para empresas.;70
5;credito pyme bana para hacer crecer tu negocio;50
5;credito pyme bana para hacer crecer tu negocio;52
5;credito pyme bana para hacer crecer tu negocio;70
5;credito pyme bana para hacer crecer tu negocio;71
6;comercial que te hace pensar en considerar a bana para poner tu negocio;50
6;comercial que te hace pensar en considerar a bana para poner tu negocio;71
7;este anuncio da una breve explicación sobre el tratamiento de hemodialisis;50
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;50
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;52
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;70
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;71
9;bonito;NONE
File 2:
ID;Coments;Category
2;es un anuncio interesante que le puede servir para alguien;321
3;es un anuncio de un banco que quiere presentarse como una compañía;57
4;es un anuncio de un banco que ofrece prestamos para empresas.;50
5;credito pyme bana para hacer crecer tu negocio;52
6;comercial que te hace pensar en considerar a bana para poner tu negocio;50
7;este anuncio da una breve explicación sobre el tratamiento de hemodialisis;210
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;50
9;bonito;303
Desired Output:
For the ID-2, we have achieved a 100% success rate.
For the ID-3, we have achieved a category.
For the ID-4, we have achieved a 100% success rate.
For the ID-5, we achieved a 25% success rate.
For the ID-5, we achieved a 50% success rate.
For the ID-7, we have achieved a 100% success rate.
For the ID-8, we have achieved a 25% success rate.
For the ID-9, we have achieved a category.
One approach could be this small. But of course, I need to calculate percentages and print it on like my desired output format.
awk 'BEGIN { FS=OFS=";" } NR==FNR{cnt[$1]++; next} { cnt2[$1]++;} END{ for (ID in cnt){ print ID, "CAT: "cnt[ID],"Manual: "cnt2[ID];}}'
Awk is for this
awk -F ';' '
FNR==1{next}
FNR==NR{C1[$1]++;N1[$1]=($3!~/NONE/);next}
{C2[$1]++;if($3!~/NONE/)N2[$1]++}
END{
for(c in C1){
if((N1[c]==0)&&(C2[c]>0)&&(N2[c]>0)){
S="we have achieved a category."
}
else S=sprintf( "we have achieved a %d%% success rate.", C2[c]*100/C1[c])
printf "For the ID-%d, %s\n", c, S
}
}' file1 file2

Resources