5
1

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 5 years have passed since last update.

ColaboratoryにJsonファイルをアップロードしてPandasで読み込む

Posted at

やったこと

コード

from google.colab import files
import io
import pandas as pd

uploaded = files.upload()
df = pd.read_json(io.StringIO(uploaded['sample.json'].decode('utf-8')))

print(df.loc[:,['id', 'text']])

実行結果

                         id                              text
0                  features                          Features
1    b_l4reliTdWOSn9SiCmbJQ                              機能紹介
2              book-example                      Book example

本当にやりたかったこと

  • Beautiful SoupでHackMDへログイン状態でアクセス
  • Beautiful Soupで履歴データ(json形式)をエクスポート機能で取得
  • Googleスプレッドシートに内容を出力

HackMDはログインフォームが無いタイプ(GoogleやFacebookで外部認証する系)なのだが、Beautiful Soupを使ってスクレイピングする方法がちょっと調べた限りでは分からなかった。
ひとまず手動でjsonファイルをダウンロードしてさわりだけ試してみた。

5
1
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?