Code : Tout sélectionner
#include <inet.au3>
#include <array.au3>
MsgBox(0,'', '1 Kilowatts Hour = ' &_GoogleUnitConvert(1, 'Kilowatts Hour', 'Joules')& ' Joules')
MsgBox(0,'', '1 miles = ' &_GoogleUnitConvert(1, 'mile', 'metre')& ' metre')
MsgBox(0,'', '100 centimetre = ' &_GoogleUnitConvert(100, 'centimetre', 'metre')& ' metre')
MsgBox(0,'', '1 kilomètre = ' &_GoogleUnitConvert(1, 'kilometer', 'metre')& ' metre')
MsgBox(0,'', '100 mils = ' &_GoogleUnitConvert(100, 'mils', 'centimetre')& ' centimetre')
MsgBox(0,'', '1 inch = ' &_GoogleUnitConvert(1, 'inch', 'mils')& ' mils')
MsgBox(0,'', '1 kilo gramme = ' &_GoogleUnitConvert(1, 'kilo gramme', 'gramme')& ' gramme')
MsgBox(0,'', '1 dollar = ' &_GoogleUnitConvert(1, 'dollar', 'euro')& ' euro')
Func _GoogleUnitConvert($sValue, $sFrom, $sTo)
Local $sSource
$sSource = _INetGetSource("http://www.google.com/search?q=" & $sValue & "%20" & StringLower($sFrom) & "%20in%20" & StringLower($sTo))
If @error Then Return SetError(1)
$sSource = StringRegExp($sSource, '<h2(.*?)<b>(.*?)</b></h2>', 1)
$sSource = StringRegExp($sSource[1], '=\s(.*?)\s[a-z]*(\s?[a-z]*?)', 1)
Return StringReplace($sSource[0], Chr(160), '')
EndFunc ;==>_GoogleUnitConvert