Skip to content

Instantly share code, notes, and snippets.

Avatar

umihico

View GitHub Profile
@umihico
umihico / get_image_path_and_current_cell.bas
Last active May 18, 2018
エクセルシート上の画像のファイル名とセル位置の隣に入力し保存するマクロ
View get_image_path_and_current_cell.bas
Attribute VB_Name = "Module1"
Sub get_image_path_and_current_cell()
Dim pic As Shape, TCht As Object
Dim ACWidth As Long, ACHeight As Long
For Each pic In ActiveSheet.Shapes
Debug.Print (pic.AlternativeText)
Range(pic.TopLeftCell.Address).Offset(0, 1) = pic.AlternativeText
ACWidth = pic.Width
ACHeight = pic.Height
@umihico
umihico / get_investment_urls_wikipedia.py
Last active Jul 10, 2018
各上場企業のwikipediaのurlを取得する
View get_investment_urls_wikipedia.py
from umihico_commons.chrome_wrapper import Chrome
def get_investment_urls_wikipedia():
parent_url_dict = {
"札証上場企業": "https://ja.wikipedia.org/wiki/Category:%E6%9C%AD%E8%A8%BC%E4%B8%8A%E5%A0%B4%E4%BC%81%E6%A5%AD",
"ジャスダック上場企業": "https://ja.wikipedia.org/wiki/Category:%E3%82%B8%E3%83%A3%E3%82%B9%E3%83%80%E3%83%83%E3%82%AF%E4%B8%8A%E5%A0%B4%E4%BC%81%E6%A5%AD",
"東証PRO上場銘柄": "https://ja.wikipedia.org/wiki/Category:%E6%9D%B1%E8%A8%BCPRO%E4%B8%8A%E5%A0%B4%E9%8A%98%E6%9F%84",
"東証一部上場企業": "https://ja.wikipedia.org/wiki/Category:%E6%9D%B1%E8%A8%BC%E4%B8%80%E9%83%A8%E4%B8%8A%E5%A0%B4%E4%BC%81%E6%A5%AD",
"東証二部上場企業": "https://ja.wikipedia.org/wiki/Category:%E6%9D%B1%E8%A8%BC%E4%BA%8C%E9%83%A8%E4%B8%8A%E5%A0%B4%E4%BC%81%E6%A5%AD",
@umihico
umihico / get_stock_metadata.py
Last active Jul 10, 2018
東京証券取引所のdata_j.xls「東証上場銘柄一覧(20xx年x月末)」からデータ取得
View get_stock_metadata.py
from io import BytesIO
from requests import get
from umihico_commons.xlsx_wrapper import _load_xlsx
import xlrd
def get_stock_metadata():
url = "https://www.jpx.co.jp/markets/statistics-equities/misc/tvdivq0000001vg2-att/data_j.xls"
response = get(url)
with BytesIO(response.content) as f:
@umihico
umihico / get_all_company_urls_wiki.py
Last active Jul 11, 2018
wikipedia上の日本企業全てのurlを取得する
View get_all_company_urls_wiki.py
from requests import get
from lxml import html
def get_all_company_urls_wiki():
base_url = "https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E3%81%AE%E4%BC%81%E6%A5%AD%E4%B8%80%E8%A6%A7"
url_dict = {
"水産・農林の企業の一覧": "https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E3%81%AE%E4%BC%81%E6%A5%AD%E4%B8%80%E8%A6%A7_(%E6%B0%B4%E7%94%A3%E3%83%BB%E8%BE%B2%E6%9E%97)",
"鉱業の企業の一覧": "https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E3%81%AE%E4%BC%81%E6%A5%AD%E4%B8%80%E8%A6%A7_(%E9%89%B1%E6%A5%AD)",
"建設の企業の一覧": "https://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E3%81%AE%E4%BC%81%E6%A5%AD%E4%B8%80%E8%A6%A7_(%E5%BB%BA%E8%A8%AD)",
@umihico
umihico / get_info_wikipedia.py
Last active Jul 11, 2018
wikipedia単ページのスクレイピング
View get_info_wikipedia.py
def get_info_wikipedia(lxml_htmltree):
result = {}
title = lxml_htmltree.xpath(
"//h1[@id='firstHeading']")[0].text_content()
result = {"title": title}
result.update(_get_righttop_infobar(lxml_htmltree))
return result
@umihico
umihico / get_address_regex.py
Last active Jul 11, 2018
大量のテキストから住所を抜き出す
View get_address_regex.py
import re
def get_address_regex_lxmltree(lxmltree):
address_list = []
for text in lxmltree.itertext():
address_list.extend(get_address_regex_text(text))
return address_list
@umihico
umihico / get_stock_info_yahoo.py
Last active Jul 12, 2018
yahooファイナンスから銘柄情報を取得する
View get_stock_info_yahoo.py
def gen_url(stock_code="8604"):
fundamental_url = f"https://profile.yahoo.co.jp/fundamental/{stock_code}"
consolidate_url = f"https://profile.yahoo.co.jp/consolidate/{stock_code}"
independent_url = f"https://profile.yahoo.co.jp/independent/{stock_code}"
urls = [fundamental_url, consolidate_url, independent_url]
return urls
def get_stock_info_yahoo(lxmltrees):
@umihico
umihico / detect_text.py
Last active Jul 17, 2018
google画像認識を使って画像から文字起こしする  https://youtu.be/gQ-9aTBlgvA
View detect_text.py
import ast
import base64
import json
from requests import post
from passpacker import passwords
from pprint import pprint
from io import BytesIO
from umihico_commons.functools import chunks
@umihico
umihico / get_yauc_closed_list.py
Last active Jul 18, 2018
ヤフオクの終了済み商品一覧をリスト化する https://youtu.be/GC3pOZTRPR0
View get_yauc_closed_list.py
def _yauc_strip(string):
deletings = (' ', " ", "\n", "\t", "\xa0")
for deleting in deletings:
string = string.replace(deleting, "")
if string.startswith(":") or string.startswith(":"):
string = string[1:]
return string
@umihico
umihico / join_videos.bat
Created Aug 4, 2018
windowsコマンドプロンプト・ffmpeg経由でmp4,mov動画ファイルを結合
View join_videos.bat
for %%i in (*.mp4 *.mov) do (
ffmpeg -i %%i -c copy -bsf:v h264_mp4toannexb -f mpegts %%i.ts
)
type nul > _list.txt
for %%i in (*.ts) do (echo file %%i) >> _list.txt
ffmpeg -f concat -i _list.txt -c copy concated_temp.ts
ffmpeg -i concated_temp.ts -c copy -bsf:a aac_adtstoasc output.mp4