LoginSignup
0
4

More than 5 years have passed since last update.

毎日たくさんのWebサイトを定期的に見ている人へ送るスクリプト

Last updated at Posted at 2017-04-15

はじめに

毎日30個くらいのWebサイトをチェックしているので、それをターミナルから操作するスクリプトを書きました。

かんたんなやり方

いつも同じページで、10ページくらいしかみない人

  1. フォルダーにブックマークする
  2. すべてのブックマークを開くを選ぶ
  3. すべてのリンクが同時に開きます

スクリーンショット 2017-04-15 15.03.32.png

今回のスクリプト

仕様

  • たまに更新される
  • テキストファイルでリンクが渡される
  • 5ページくらいずつ開きたい
  • たまにhttpすらついてないやつが来る
  • LINES_NUM = 2のとこをいじると、何ページずつ開くか選べる

コード


# coding: utf-8

import webbrowser

LINES_NUM = 2

urls = """
https://www.google.co.jp/
https://github.com/

qiita.com
"""

urls = [url for url in urls.split("\n") if url]

for i, url in enumerate(urls, 1):

    # correct url
    if not url.startswith("http"):
        url = "http://" + url

    webbrowser.open_new_tab(url)

    # stop each line by standard input
    if i % LINES_NUM == 0:
        raw_input("type something >> ")

コメント欄でいい感じに直していただいたので感謝ですm(_)m

スクリーンショット 2017-04-15 15.09.05.png

こんな感じで[type something >> ]とくるので適当にEnterを押してやると、次の指定行(LINES_NUM = 2)が読まれます。

参考

空行削除: リストから空の要素を削除する

0
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
4