LoginSignup
6
7

More than 5 years have passed since last update.

AKBメンバーのGoogle+ IDを一気に取得する

Posted at

SNSからデータを取得して、分析する練習をする時、AKBグループメンバーのGoogle+投稿を使用すると非常に楽しいです。それなりの分量もありますし。

メンバーのGoogle+ IDを、下記のサイトから一気に出力します。
http://www.google.com/intl/ja/+/project48/

BeautifulSoupというモジュールを使用します。下記がそのサイトです。
http://www.crummy.com/software/BeautifulSoup/
pip installでインストールできます。

Pythonで下記のようなスクリプトを書きました。
この例では結果をprintしていますが、リストとして別の処理に渡して、順次Activityを取得する、というような使い方ができると思います。

gidprint.py

#!bin/python
#coding: utf-8

from BeautifulSoup import BeautifulSoup
import urllib

def gidlist_make():
    soup = BeautifulSoup(urllib.urlopen("http://www.google.com/intl/ja/+/project48/").read())
    lisoup=[]
    gidlist = []
    for lisoup in soup.findAll("li"):

        try:
            gidlist.append(lisoup['data-gplusid'])
        except:
            continue

    return gidlist

if __name__=='__main__':
    gidlist= gidlist_make()
    for gid in gidlist:


6
7
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
6
7