LoginSignup
1
0

More than 3 years have passed since last update.

Elasticsearch の plug-in の指定サイトの最新バージョンをチェックしてみる

Last updated at Posted at 2020-06-05

Elasticsearch の plug-in の指定サイトの最新バージョンをチェックしてみる

目的

Fessで使用するElasticsearchのpluginの最新バージョンをチェックしてみる
Docs » ドキュメント » Fess インストールガイド » インストール
に記述されている以下のpluginを対象にする


$ ./elasticsearch-/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-fess:7.7.0
$ ./elasticsearch-/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-extension:7.7.0
$ ./elasticsearch-/bin/elasticsearch-plugin install org.codelibs:elasticsearch-configsync:7.7.0
$ ./elasticsearch-/bin/elasticsearch-plugin install org.codelibs:elasticsearch-dataformat:7.7.0
$ ./elasticsearch-/bin/elasticsearch-plugin install org.codelibs:elasticsearch-minhash:7.7.0

各ページをorg/codelibsよりローカルにDL後、名前を修正してデバッグしている
※本家に対しては未だ動かしていない・・・
辞書を使って集計とかはVBAではよくやっているんだけど、これで良いのかな?

サンプルコード

# Windows Add env PYTHONIOENCODING = UTF-8 & restart vscode

import re
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
import chromedriver_binary

# ブラウザーを起動
options = Options()
options.binary_location = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)

# チェック対象となるページ
alist = [
    'analysis-fess.html',
    'analysis-extension.html',
    'configsync.html',
    'dataformat.html',
    'minhash.html'
]

# 集計用の辞書
adict = {}

tgurl = 'http://localhost:8080/'

try:
    # 5ページ分Loop
    for lst in alist:
        driver.get(tgurl + lst)
        print(tgurl + lst)
        element = WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.TAG_NAME, 'a'))
        )
        xpath = "/html/body/main/pre/a"
        elems = driver.find_elements_by_xpath(xpath)
        # adict['pluginのバージョン'] = 個数
        for elem in elems:
            # \. では無いのか・・・
            atext = re.sub('[/|.]', '',  elem.text)
            # atext = elem.text.replace("/","").replace(".","")
            if atext.isdecimal():
                if atext in adict.keys():
                    # 7.7.0/ -> 770 が辞書に存在すれば1を加算
                    adict[atext] =  adict[atext] + 1
                else:
                    # 新規は個数1
                    adict[atext] = 1                    
        # time.sleep(2)   # for Debug

    # pluginのバージョンでソートする
    dic1 = sorted(adict.items(), reverse=True)
    # pluginのバージョンの最大値から個数=5が見つかるまでループ
    for dic in dic1:
        lt = list(dic)
        if lt[1] == 5:
            # このバージョンを指定してpluginをDLする
            print(str(lt[0]) + ':' + str(lt[1]))
            break

finally:
    print('done')
    driver.quit()

参考にしたサイトはこちら

Docs » ドキュメント » Fess インストールガイド » インストール
org/codelibs
【Python入門】dictionary(辞書)の使い方。基本と応用
Pythonの正規表現モジュールreの使い方(match、search、subなど)
Fess の plug-in のサイトをxpathを使用して検索&表示してみる

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0