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
Reference
이 문제에 관하여(ls보다 더 유용한 로 명령을 만들었어요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/sessions/items/a4fa1e0c83418d728c45
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
#! /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
Reference
이 문제에 관하여(ls보다 더 유용한 로 명령을 만들었어요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/sessions/items/a4fa1e0c83418d728c45
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(ls보다 더 유용한 로 명령을 만들었어요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/sessions/items/a4fa1e0c83418d728c45텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)