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?

More than 3 years have passed since last update.

AWS BlackBeltのPDFをローカルに取得して学習効率化を図る(ブックマークレット)

Posted at

AWS BlackBeltのPDFをローカルに取得して学習効率化を図る(ブックマークレット)

やること

AWS BlackBeltのPDFをローカルに取得するためのCURLコマンドを生成する
ローカルに取得して学習効率化を図ろう!

できること

BackBeltのPDFを取得するためのCURLコマンドがクリップボードにコピーされます。

前提条件

やりかた

ブックマークレットでサクッと

以下をブックマークレットとしてブラウザに登録してください。

javascript:function zeroPadding(num,length){    return ('0000000000' + num).slice(-length);}function execCopy(string) {  var tmp = document.createElement("div");  var pre = document.createElement("pre");  pre.style.webkitUserSelect = "auto";  pre.style.userSelect = "auto";  tmp.appendChild(pre).textContent = string;  var s = tmp.style;  s.position = "fixed";  s.right = "200%";  document.body.appendChild(tmp);  document.getSelection().selectAllChildren(tmp);  var result = document.execCommand("copy");  document.body.removeChild(tmp);  return result;}var seq = 0;var ret = [];document.querySelectorAll(".aws-table").forEach(el=>{  var category = el.parentElement.previousElementSibling.innerText;  seq = seq + 1;  var seqStr = zeroPadding(seq, 2);  if(category) { category = category.split(" ").join(""); }    el.querySelectorAll("tr").forEach(tr=>{    var tds = tr.querySelectorAll("td");    if(tds[4] && tds[4].innerText == "PDF") {      var serviceName = tds[0].innerText;      var publishDate = tds[1].innerText;      var title = tds[2].innerText;      var fileName = [seqStr,category,serviceName,publishDate,title].join("_") + ".pdf";      fileName = fileName.split("/").join("-");      fileName = fileName.split(" ").join("");      fileName = fileName.split("\n").join("");      fileName = fileName.split(":").join("");      var pdfPath = "https:" + tds[4].querySelector("a").getAttribute("href");      var command = `curl ${pdfPath} -o "${fileName}"`;      ret.push(command);    }  });});execCopy(ret.join("\r\n"));alert("コマンドのコピーが完了しました!");

使い方

image.png

  • コマンドプロンプト(curlが実行できるコンソールを開く)
  • 取得したい任意のディレクトリに移動

image.png

  • コピーされたコマンドを貼り付ける!

image.png

取得が終わるのを待ちます...

以上!

解説

  • 追って記載します...
整形


あとがき

取得対象の要素名(クラス名など)が変わると動かなくなります。
2020-07-23現在動いているので目次を取りたい際は試してみて下さい。

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?