0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

たくさんあるリンクを自動で開く時 (自分用メモ)

Posted at

jsonファイルを使い、jsonファイルを読み込んで開くやり方が楽

一個しか開けないwebbrowser.openは、大量リンクがあるとき使えない


使うjsonファイル 注意点

ファイルを囲うとき、必ずダブルクオテーション → ”

url.json
{
  "urls": [
"https://prtimes.jp/main/html/rd/p/000000080.000005698.html",

"https://news.mynavi.jp/techplus/article/security_ransomware02-pPbsjdDk/"
          ]
}

pythonファイルの中身

たくさんURLがあるから、配列 forで必ずループさせる

たくさんURLがあるから、timeで時間をあけて開くよう設定

jsonファイルを使うときは、必ず import json

sample.py
import json
import webbrowser
import time

with open('url.json', 'r') as file:
    data = json.load(file)

# URLのリストを取得
urls = data['urls']

# 各URLを自動で開く
for url in urls:
    webbrowser.open(url)

感想

pythonのコード、わかりやすいぃ

0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?