shizupptx
TRANSCRIPT
Pythonでpptx
@kzfm
GUIに頼らずpptxを作れると素敵
• パターンの再利用 • 作業の自動化
• Sphinxに慣れすぎた
• powepointたまに死ぬ(-‐>発狂する)
python-‐pptx
• h8ps://github.com/scanny/python-‐pptx • pip install python-‐pptx • 開発はじまったばかり • 超期待!
アイドル水着画像をあつめてpptxに貼る
c = requests.get('h8p://matome.naver.jp/odai/2135350364969742801').content urls = [x.group(1) for x in re.finditer(r'<img src="(.+)".*?class="MTMItemThumb".*?/>', c)]
for i, url in enumerate(urls[:10], 1): img_path = "{}.jpg".format(i) r = requests.get(url) if r.status_code == 200: img = r.content with open(img_path, 'w') as f: f.write(img) shapes = prs.slides.add_slide(bullet_slidelayout).shapes shapes.placeholders[0].text = '水着アイドル ({})'.format(i) top = Inches(1.5) led = Inches(3) width = Px(280) height = int(width * 1.427) pic = shapes.add_picture(img_path, led, top, width, height)
水着アイドル (1)
水着アイドル (2)
水着アイドル (3)
水着アイドル (4)
水着アイドル (5)
水着アイドル (6)
水着アイドル (7)
水着アイドル (8)
水着アイドル (9)
水着アイドル (10)
このスライドはpython-‐pptx製
• スクリプトっぽい(DSLっぽくはない) • 再利用性は高められそう • Gitで管理できる(重要!)
• Sphinxの拡張にするのは面白そう • livereloadで更新時にリロードしないかなぁ?
まとめ (真のアイドルは焼津)