ls보다 더 유용한 로 명령을 만들었어요.

5269 단어 Python

ls의 시대가 끝났어요.


나는 많은 사람들이 종착역에 닿자마자 먼저 전화를 한다고 생각한다ls. 그러나 이것은 단지 시간을 낭비하는 것에 불과하다. 이것은 이미 모두가 알고 있는 사실이므로 더욱 의미 있게 시간을 사용해야 한다.
아는 서류 한 번 훑어봐도 좋을 거 없잖아.
그래서 나는 ls보다 더 유용한 lo 명령을 제정했다.
이름 그대로 최신 COMIC LO의 타이틀을 따서 선명한 분홍색으로 출력ls하는 것보다 더 유용한 지령이다.ping도 대체() 가능

다음 ptyhon 스크립트는 PATH가 통과하는 곳lo에 배치됩니다.
#! /usr/bin/env python3
from urllib.request import urlopen
import re

with urlopen("http://www.akaneshinsha.co.jp/category/item/itemgenre/itemad/magazine-ad/comic-lo/") as res:
    html = res.read().decode("utf-8")
urlprefix = "http://www.akaneshinsha.co.jp/item/"
founds = re.findall(r'<a href="{}(\d+?)/?".+?>'.format(urlprefix), html)
if not founds:
    quit()

with urlopen(urlprefix + founds[0]) as res:
    html = res.read().decode("utf-8").replace("\n", " ")
founds = re.findall(
    r'<div class="freetxt">\s*<p>.+?</p>\s*<p>(.+?)</p>', html)
if not founds:
    quit()
founds = re.findall(r'「(.+?)」', founds[0])
color = 202
for i, found in enumerate(founds):
    print('\033[38;5;%dm%s\033[0m' % (color, found))
    if (i + 1) % (max(4, len(founds)) // 4) == 0:
        color += 1

총결산


COMIC LO is god

TODO


-l-a-h

좋은 웹페이지 즐겨찾기