{"id":439,"date":"2021-06-03T05:46:28","date_gmt":"2021-06-02T20:46:28","guid":{"rendered":"https:\/\/mowareblog.net\/3rd\/?p=439"},"modified":"2021-06-03T20:11:44","modified_gmt":"2021-06-03T11:11:44","slug":"%e7%84%a1%e7%b7%9a-03-python%e3%81%a7adif%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e4%bd%9c%e6%88%90-%e5%be%8c%e7%b7%a8","status":"publish","type":"post","link":"https:\/\/mowareblog.net\/3rd\/2021\/06\/439\/%e7%84%a1%e7%b7%9a-03-python%e3%81%a7adif%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e4%bd%9c%e6%88%90-%e5%be%8c%e7%b7%a8\/","title":{"rendered":"[\u7121\u7dda] 03 Python\u3067ADIF\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210 \u5f8c\u7de8"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">[macOS Catalina 10.15.7]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u524d\u56de\u306e\u7d9a\u304d\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">eQSL\u30b5\u30a4\u30c8\u306b\u79fb\u52d5\u5c40\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u3092\u767b\u9332\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u767b\u9332\u3057\u3066\u3044\u306a\u3051\u308c\u3070\u672b\u5c3e\u306a\u3057\u306e\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u3078eQSL\u30ab\u30fc\u30c9\u3092\u9001\u4ed8\u3059\u308b\u3088\u3046ADIF\u30d5\u30a1\u30a4\u30eb\u3092\u66f8\u304d\u63db\u3048\u308b\u3001\u3068\u3044\u3063\u305f\u5185\u5bb9\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">VBA\u3067\u3082\u540c\u69d8\u306e\u4f5c\u696d\u304c\u3067\u304d\u308b\u304b\u3069\u3046\u304b\u691c\u8a3c\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u304c\u3001Mac\u7248Excel\u3067\u306f\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u304c\u3067\u304d\u306a\u3044\u306e\u3067\u6c17\u304c\u5411\u3051\u3070Windows\u7248Excel\u3067\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>\uff1c\u524d\u7de8\u304b\u3089\u306e\u7d9a\u304d\uff1e\n\ndriver = webdriver.Chrome()\nwindow_num = 1\nfor i,call in enumerate(call_l):\n    print(call)\n    print(f&#39;\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u6587\u5b57\u6570 {len(call)}&#39;)\n    if len(call) == 8:\n\u3000\u3000\u3000\u3000\u3000# eQSl\u30b5\u30a4\u30c8\u306eURL\u3092\u53d6\u5f97\n        driver.get(&quot;https:\/\/www.eqsl.cc\/QSLcard\/Home4G.cfm&quot;)\n\n        WebDriverWait(driver,30).until(EC.presence_of_element_located((By.XPATH, &quot;\/html\/body\/div[2]\/form[2]\/font\/input[2]&quot;)))\n\n\u3000\u3000\u3000\u3000\u3000# \u691c\u7d22\u7a93\u306b\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u3092\u5165\u529b\u3059\u308b\n        driver.find_element_by_xpath(&quot;\/html\/body\/div[2]\/form[2]\/font\/input[1]&quot;) \\\n.send_keys(call)\n\n        tm.sleep(1)\n\n        # \u691c\u7d22\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\n        driver.find_element_by_xpath(&quot;\/html\/body\/div[2]\/form[2]\/font\/input[2]&quot;) \\\n.click()\n        # \u65b0\u3057\u3044\u30a6\u30a3\u30f3\u30c9\u30a6\u3078\u9077\u79fb\u3059\u308b\n        handle_array = driver.window_handles\n        driver.switch_to.window(handle_array[window_num])\n\n        WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH, &quot;\/\/*[@id=&#39;CFForm_1&#39;]\/input[2]&quot;)))\n\n\u3000\u3000\u3000\u3000\u3000# \u691c\u7d22\u7d50\u679c\u306e\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b\n        text = driver.find_element_by_xpath(&quot;\/html\/body\/center\/h2\/font&quot;).text\n        print(text)\n\n        # \u691c\u7d22\u7d50\u679c\u306bnot\u304a\u3088\u3073yet\u304c\u542b\u307e\u308c\u3066\u3044\u305f\u3089\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u306e\u672b\u5c3e2\u6587\u5b57\u3092\u524a\u9664\u3057ADIF\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u63db\u3048\u308b\n        # \u691c\u7d22\u7d50\u679c\u4f8b:&quot;JA3AAA\/3 is not registered yet&quot;\n        if &#39;not&#39; in text and &#39;yet&#39; in text:\n            new_str1 = data_l[i].replace(&#39;&lt;CALL:8&gt;&#39;,&#39;&lt;CALL:6&gt;&#39;)\n            new_str2 = new_str1[:14] + new_str1[16:]\n            print(new_str2)\n            \n            # ADIF\u30c7\u30fc\u30bf\u3092\u7f6e\u304d\u63db\u3048\u308b\n            data_l[i] = new_str2\n\n        window_num +=1\n\n# \u30d6\u30e9\u30a6\u30b6\u3092\u9589\u3058\u308b\ndriver.quit()\n\n# AGIF\u30c7\u30fc\u30bf\u3092\u6539\u884c\u30b3\u30fc\u30c9\u3067\u9023\u7d50\u3059\u308b\ndata_l2 = &#39;\\n&#39;.join(data_l)\n\n# \u30d8\u30c3\u30c0\u3068AGIF\u30c7\u30fc\u30bf\u3092\u7d50\u5408\u3059\u308b\nheader = &#39;&lt;PROGRAMID:6&gt;HAMLOG\\n&lt;ADIF_Ver:5&gt;3.1.0\\n&lt;EOH&gt;\\n&#39;\nfinal = header + data_l2\n\n# \u7d50\u5408\u3057\u305f\u30c7\u30fc\u30bf\u3092adi\u30d5\u30a1\u30a4\u30eb(\u30d7\u30ec\u30fc\u30f3\u30c6\u30ad\u30b9\u30c8)\u306b\u5909\u63db\u3059\u308b\nfilename2 = f&quot;\/adif\/{datetime_now_str}_adif.adi&quot;\nwith open(filename2, &quot;w&quot;, encoding=&quot;shift_jis&quot;) as f2:\n    f2.write(final)\n\n# \u524d\u7de8\u3067\u4f5c\u6210\u3057\u305fCSV\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308b\nos.remove(filename)<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f5c\u6210\u3055\u308c\u305fADIF\u30d5\u30a1\u30a4\u30eb\u306e\u4e00\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-json\" data-lang=\"JSON\"><code>&lt;PROGRAMID:6&gt;HAMLOG\n&lt;ADIF_Ver:5&gt;3.1.0\n&lt;EOH&gt;\n&lt;CALL:6&gt;JA3AAA&lt;QSO_DATE:8:D&gt;20210602&lt;TIME_ON:4&gt;0611&lt;BAND:2&gt;2m&lt;MODE:2&gt;FM \\\n&lt;RST_SENT:3&gt;59+&lt;RST_RCVD:0&gt;&lt;QSL_SENT:1&gt;Y&lt;QSL_SENT_VIA:1&gt;E&lt;QSLMSG:6&gt;CU 73! \\\n&lt;APP_EQSL_AG:1&gt;Y&lt;GRIDSQUARE:4&gt;AA00&lt;EOR&gt;\n&lt;CALL:6&gt;JZ3ZZZ&lt;QSO_DATE:8:D&gt;20210602&lt;TIME_ON:4&gt;0730&lt;BAND:4&gt;70cm&lt;MODE:2&gt;FM \\\n&lt;RST_SENT:3&gt;59+&lt;RST_RCVD:0&gt;&lt;QSL_SENT:1&gt;Y&lt;QSL_SENT_VIA:1&gt;E&lt;QSLMSG:6&gt;CU 73! \\\n&lt;APP_EQSL_AG:1&gt;Y&lt;GRIDSQUARE:4&gt;AA00&lt;EOR&gt;<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>[macOS Catalina 10.15.7] \u524d\u56de\u306e\u7d9a\u304d\u3067\u3059\u3002 eQSL\u30b5\u30a4\u30c8\u306b\u79fb\u52d5\u5c40\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u3092\u767b\u9332\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u767b\u9332\u3057\u3066\u3044\u306a\u3051\u308c\u3070\u672b\u5c3e\u306a\u3057\u306e\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u3078eQSL\u30ab\u30fc\u30c9\u3092\u9001\u4ed8\u3059\u308b\u3088\u3046ADIF\u30d5\u30a1\u30a4\u30eb &hellip; <a href=\"https:\/\/mowareblog.net\/3rd\/2021\/06\/439\/%e7%84%a1%e7%b7%9a-03-python%e3%81%a7adif%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e4%bd%9c%e6%88%90-%e5%be%8c%e7%b7%a8\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">[\u7121\u7dda] 03 Python\u3067ADIF\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210 \u5f8c\u7de8<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-439","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/posts\/439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/comments?post=439"}],"version-history":[{"count":10,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/posts\/439\/revisions"}],"predecessor-version":[{"id":470,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/posts\/439\/revisions\/470"}],"wp:attachment":[{"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/media?parent=439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/categories?post=439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/tags?post=439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}