まったく 入門とは思えない オライリーのMining the Social Web(入門 ソーシャルデータ)その1 ― 2013/07/17 01:39
オライリーの入門 ソーシャルデータを購入
data Miningを少し勉強しようとおもって
しかし、初っぱなから 悪戦苦闘してます。
まず 例が動かない。
オライリージャパンの正誤表も古いし、本家のも NG
http://nbviewer.ipython.org/urls/raw.github.com/ptwobrussell/Mining-the-Social-Web/master/ipython_notebooks/Chapter1.ipynb
のを読み出して
まずは twitterの認証システムが違うので
CONSUMER_KEY = '***'
CONSUMER_SECRET = '***'
OAUTH_TOKEN = '***'
OAUTH_TOKEN_SECRET = '***'
を取得してきて ***に入れて 動かす
P6ページの例(exsample 1.3)は動いた
結果は
[{u'created_at': u'2013-07-16T16:36:22Z', u'trends': [{u'url': u'http://twitter.com/search?q=%23LukeHemmingsFollowParty', u'query': u'%23LukeHemmingsFollowParty', u'name': u'#LukeHemmingsFollowParty', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%23IfICouldWishForAnything', u'query': u'%23IfICouldWishForAnything', u'name': u'#IfICouldWishForAnything', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%23LuaBlancoNaCapaDaAtrevida', u'query': u'%23LuaBlancoNaCapaDaAtrevida', u'name': u'#LuaBlancoNaCapaDaAtrevida', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%23MelFronckowiakNaCapaDaAtrevida', u'query': u'%23MelFronckowiakNaCapaDaAtrevida', u'name': u'#MelFronckowiakNaCapaDaAtrevida', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%23ChaySuedeNaCapaDaAtrevida', u'query': u'%23ChaySuedeNaCapaDaAtrevida', u'name': u'#ChaySuedeNaCapaDaAtrevida', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=AssistaWebs%C3%A9rieFlynaCapricho', u'query': u'AssistaWebs%C3%A9rieFlynaCapricho', u'name': u'AssistaWebs\xe9rieFlynaCapricho', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%221D+Nobody+Compares+To+Poland%22', u'query': u'%221D+Nobody+Compares+To+Poland%22', u'name': u'1D Nobody Compares To Poland', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=Julien', u'query': u'Julien', u'name': u'Julien', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=Emilie', u'query': u'Emilie', u'name': u'Emilie', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=Z-40', u'query': u'Z-40', u'name': u'Z-40', u'promoted_content': None, u'events': None}], u'as_of': u'2013-07-16T16:37:15Z', u'locations': [{u'woeid': 1, u'name': u'\u4e16\u754c\u4e2d'}]}]
ここで やっと本に戻って確認、でも何がなにやら
http://search.twitter.com/1/trends.json
を入力すると 1.1使えってエラーでるし
さらに 1−4を実行しようとすると indentがズレてしまっていて エディターでインデントを確認してやっと
結果が
[
{
"created_at": "2013-07-16T16:36:22Z",
"trends": [
{
"url": "http://twitter.com/search?q=%23LukeHemmingsFollowParty",
"query": "%23LukeHemmingsFollowParty",
"name": "#LukeHemmingsFollowParty",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%23IfICouldWishForAnything",
"query": "%23IfICouldWishForAnything",
"name": "#IfICouldWishForAnything",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%23LuaBlancoNaCapaDaAtrevida",
"query": "%23LuaBlancoNaCapaDaAtrevida",
"name": "#LuaBlancoNaCapaDaAtrevida",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%23MelFronckowiakNaCapaDaAtrevida",
"query": "%23MelFronckowiakNaCapaDaAtrevida",
"name": "#MelFronckowiakNaCapaDaAtrevida",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%23ChaySuedeNaCapaDaAtrevida",
"query": "%23ChaySuedeNaCapaDaAtrevida",
"name": "#ChaySuedeNaCapaDaAtrevida",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=AssistaWebs%C3%A9rieFlynaCapricho",
"query": "AssistaWebs%C3%A9rieFlynaCapricho",
"name": "AssistaWebs\u00e9rieFlynaCapricho",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%221D+Nobody+Compares+To+Poland%22",
"query": "%221D+Nobody+Compares+To+Poland%22",
"name": "1D Nobody Compares To Poland",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=Julien",
"query": "Julien",
"name": "Julien",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=Emilie",
"query": "Emilie",
"name": "Emilie",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=Z-40",
"query": "Z-40",
"name": "Z-40",
"promoted_content": null,
"events": null
}
],
"as_of": "2013-07-16T16:37:15Z",
"locations": [
{
"woeid": 1,
"name": "\u4e16\u754c\u4e2d"
}
]
}
]
まとめ、
1.twitterの認証キーを取得
2.本の通り動かないので googleか調べる
3.python結構しらないと twitterのデータ構造とかを調べられない(python必修:誰かrubyで置き換えてないかな?)
4.エディターで構文check(エラーみると単純ミスが多い)
data Miningを少し勉強しようとおもって
しかし、初っぱなから 悪戦苦闘してます。
まず 例が動かない。
オライリージャパンの正誤表も古いし、本家のも NG
http://nbviewer.ipython.org/urls/raw.github.com/ptwobrussell/Mining-the-Social-Web/master/ipython_notebooks/Chapter1.ipynb
のを読み出して
まずは twitterの認証システムが違うので
CONSUMER_KEY = '***'
CONSUMER_SECRET = '***'
OAUTH_TOKEN = '***'
OAUTH_TOKEN_SECRET = '***'
を取得してきて ***に入れて 動かす
P6ページの例(exsample 1.3)は動いた
結果は
[{u'created_at': u'2013-07-16T16:36:22Z', u'trends': [{u'url': u'http://twitter.com/search?q=%23LukeHemmingsFollowParty', u'query': u'%23LukeHemmingsFollowParty', u'name': u'#LukeHemmingsFollowParty', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%23IfICouldWishForAnything', u'query': u'%23IfICouldWishForAnything', u'name': u'#IfICouldWishForAnything', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%23LuaBlancoNaCapaDaAtrevida', u'query': u'%23LuaBlancoNaCapaDaAtrevida', u'name': u'#LuaBlancoNaCapaDaAtrevida', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%23MelFronckowiakNaCapaDaAtrevida', u'query': u'%23MelFronckowiakNaCapaDaAtrevida', u'name': u'#MelFronckowiakNaCapaDaAtrevida', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%23ChaySuedeNaCapaDaAtrevida', u'query': u'%23ChaySuedeNaCapaDaAtrevida', u'name': u'#ChaySuedeNaCapaDaAtrevida', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=AssistaWebs%C3%A9rieFlynaCapricho', u'query': u'AssistaWebs%C3%A9rieFlynaCapricho', u'name': u'AssistaWebs\xe9rieFlynaCapricho', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=%221D+Nobody+Compares+To+Poland%22', u'query': u'%221D+Nobody+Compares+To+Poland%22', u'name': u'1D Nobody Compares To Poland', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=Julien', u'query': u'Julien', u'name': u'Julien', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=Emilie', u'query': u'Emilie', u'name': u'Emilie', u'promoted_content': None, u'events': None}, {u'url': u'http://twitter.com/search?q=Z-40', u'query': u'Z-40', u'name': u'Z-40', u'promoted_content': None, u'events': None}], u'as_of': u'2013-07-16T16:37:15Z', u'locations': [{u'woeid': 1, u'name': u'\u4e16\u754c\u4e2d'}]}]
ここで やっと本に戻って確認、でも何がなにやら
http://search.twitter.com/1/trends.json
を入力すると 1.1使えってエラーでるし
さらに 1−4を実行しようとすると indentがズレてしまっていて エディターでインデントを確認してやっと
結果が
[
{
"created_at": "2013-07-16T16:36:22Z",
"trends": [
{
"url": "http://twitter.com/search?q=%23LukeHemmingsFollowParty",
"query": "%23LukeHemmingsFollowParty",
"name": "#LukeHemmingsFollowParty",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%23IfICouldWishForAnything",
"query": "%23IfICouldWishForAnything",
"name": "#IfICouldWishForAnything",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%23LuaBlancoNaCapaDaAtrevida",
"query": "%23LuaBlancoNaCapaDaAtrevida",
"name": "#LuaBlancoNaCapaDaAtrevida",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%23MelFronckowiakNaCapaDaAtrevida",
"query": "%23MelFronckowiakNaCapaDaAtrevida",
"name": "#MelFronckowiakNaCapaDaAtrevida",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%23ChaySuedeNaCapaDaAtrevida",
"query": "%23ChaySuedeNaCapaDaAtrevida",
"name": "#ChaySuedeNaCapaDaAtrevida",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=AssistaWebs%C3%A9rieFlynaCapricho",
"query": "AssistaWebs%C3%A9rieFlynaCapricho",
"name": "AssistaWebs\u00e9rieFlynaCapricho",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=%221D+Nobody+Compares+To+Poland%22",
"query": "%221D+Nobody+Compares+To+Poland%22",
"name": "1D Nobody Compares To Poland",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=Julien",
"query": "Julien",
"name": "Julien",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=Emilie",
"query": "Emilie",
"name": "Emilie",
"promoted_content": null,
"events": null
},
{
"url": "http://twitter.com/search?q=Z-40",
"query": "Z-40",
"name": "Z-40",
"promoted_content": null,
"events": null
}
],
"as_of": "2013-07-16T16:37:15Z",
"locations": [
{
"woeid": 1,
"name": "\u4e16\u754c\u4e2d"
}
]
}
]
まとめ、
1.twitterの認証キーを取得
2.本の通り動かないので googleか調べる
3.python結構しらないと twitterのデータ構造とかを調べられない(python必修:誰かrubyで置き換えてないかな?)
4.エディターで構文check(エラーみると単純ミスが多い)
US,JPのamazonでのkindle管理 ― 2013/07/20 09:14
新規に買ったMacBookAirでkindleの端末の設定しようとしたら
パスワードが認識されない。
表示等は 全て日本語、amazon.co.jpのパスワードを入力してもユーザ名かパスワードが違うってエラーがでる
もしかしたら US側でkindle管理しているのではと USのアマゾンのパスワードを入力 認識した。登録できた
まったく 入門とは思えない オライリーのMining the Social Web(入門 ソーシャルデータ)その2 ― 2013/07/20 11:01
pythonのimport twitterを調べた
/usr/local/lib/python2.7/site-packages/twitter-1.10.0-py2.7.egg/twitter
__init__.py
初期化
ansi.py
ansiのカラム、コマンド、色指定?
api.py
twitter API URL,エラー,認証、レスポンスなど jsonを利用して行う
データ取得の接続まで
archiver.py
twitterのアーカイブ 引数、スイッチ多数
auth.py
認証のパラメータ渡し(エラーハンドリングは無い)
cmdline.py
twitter [action] [options]で twitterのコマンド群の記述用
引数、スイッチ多数
follow.py
twitter-follow [options] <user>コマンド群
ircbot.py
A twitter IRC bot. Twitterbot connected to an IRC server and idles in a channel, polling a twitter account and broadcasting all updates
logger.py
twitter-log <screen_name> [max_id]
oauth.py
oauth2.py
Visit the Twitter developer page and create a new application:
https://dev.twitter.com/apps/new
This will get you a CONSUMER_KEY and CONSUMER_SECRET.
oauth_dance.py
prompts. Return the oauth_token and oauth_token_secret.
Provide the name of your app in `app_name`, your consumer_key, and consumer_secret. This function will open a web browser to let the user allow your app to access their Twitter account. PIN authentication is used.
If a token_filename is given, the oauth tokens will be written to the file.
Perform the OAuth dance with some command-line
stream.py
urlへリクエスト、エラーハンドリング
e TwitterStream object is an interface to the Twitter Stream API
(stream.twitter.com). This can be used pretty much the same as the
Twitter class except the result of calling a method will be an
iterator that yields objects decoded from the stream. For
example::
twitter_stream = TwitterStream(auth=OAuth(...))
iterator = twitter_stream.statuses.sample()
for tweet in iterator:
...do something with this tweet...
The iterator will yield tweets forever and ever (until the stream
breaks at which point it raises a TwitterHTTPError.)
The `block` parameter controls if the stream is blocking. Default
is blocking (True). When set to False, the iterator will
occasionally yield None when there is no available message.
"""
stream_example.py
Example program for the Stream API. This prints public status messages from the "sample" stream as fast as possible.
timezones.py
# A class building tzinfo objects for fixed-offset time zones.
# Note that FixedOffset(0, "UTC") is a different way to build a
# UTC tzinfo object.
twitter_globals.py
This module is automatically generated using `update.py`
.. data:: POST_ACTIONS
List of twitter method names that require the use of POST
'''
util.py
Internal utility functions.
`htmlentitydecode` came from here:
http://wiki.python.org/moin/EscapingHtml
/usr/local/lib/python2.7/site-packages/twitter-1.10.0-py2.7.egg/twitter
__init__.py
初期化
ansi.py
ansiのカラム、コマンド、色指定?
api.py
twitter API URL,エラー,認証、レスポンスなど jsonを利用して行う
データ取得の接続まで
archiver.py
twitterのアーカイブ 引数、スイッチ多数
auth.py
認証のパラメータ渡し(エラーハンドリングは無い)
cmdline.py
twitter [action] [options]で twitterのコマンド群の記述用
引数、スイッチ多数
follow.py
twitter-follow [options] <user>コマンド群
ircbot.py
A twitter IRC bot. Twitterbot connected to an IRC server and idles in a channel, polling a twitter account and broadcasting all updates
logger.py
twitter-log <screen_name> [max_id]
oauth.py
oauth2.py
Visit the Twitter developer page and create a new application:
https://dev.twitter.com/apps/new
This will get you a CONSUMER_KEY and CONSUMER_SECRET.
oauth_dance.py
prompts. Return the oauth_token and oauth_token_secret.
Provide the name of your app in `app_name`, your consumer_key, and consumer_secret. This function will open a web browser to let the user allow your app to access their Twitter account. PIN authentication is used.
If a token_filename is given, the oauth tokens will be written to the file.
Perform the OAuth dance with some command-line
stream.py
urlへリクエスト、エラーハンドリング
e TwitterStream object is an interface to the Twitter Stream API
(stream.twitter.com). This can be used pretty much the same as the
Twitter class except the result of calling a method will be an
iterator that yields objects decoded from the stream. For
example::
twitter_stream = TwitterStream(auth=OAuth(...))
iterator = twitter_stream.statuses.sample()
for tweet in iterator:
...do something with this tweet...
The iterator will yield tweets forever and ever (until the stream
breaks at which point it raises a TwitterHTTPError.)
The `block` parameter controls if the stream is blocking. Default
is blocking (True). When set to False, the iterator will
occasionally yield None when there is no available message.
"""
stream_example.py
Example program for the Stream API. This prints public status messages from the "sample" stream as fast as possible.
timezones.py
# A class building tzinfo objects for fixed-offset time zones.
# Note that FixedOffset(0, "UTC") is a different way to build a
# UTC tzinfo object.
twitter_globals.py
This module is automatically generated using `update.py`
.. data:: POST_ACTIONS
List of twitter method names that require the use of POST
'''
util.py
Internal utility functions.
`htmlentitydecode` came from here:
http://wiki.python.org/moin/EscapingHtml
rvm mac 2.0.0環境でのruby 2.0.0のbuild エラー ― 2013/07/21 09:01
macのrvmでruby-2.0.0をbuildするとopenssl読み込めなくてエラーです
そこで
$rvm pkg install openssl
opensslを~/.rvm/usrの下に入れた
パスに~/.rvm/usrを追加
$rvm reinstall ruby-2.0.0 --with-openssl-dir=/Users/butcher/.rvm/usr/ssl --verify-downloads 1
で 今度は
gem pristine bigdecimal --version 1.2.0 io-console --version 0.4.2 json --version 1.7.7 minitest --version 4.3.2 psych --version 2.0.0 rake --version 0.9.6 rdoc --version 4.0.0 test-unit --version 2.0.0.0
を直せってエラーになった
そこで
$rvm pkg install openssl
opensslを~/.rvm/usrの下に入れた
パスに~/.rvm/usrを追加
$rvm reinstall ruby-2.0.0 --with-openssl-dir=/Users/butcher/.rvm/usr/ssl --verify-downloads 1
で 今度は
gem pristine bigdecimal --version 1.2.0 io-console --version 0.4.2 json --version 1.7.7 minitest --version 4.3.2 psych --version 2.0.0 rake --version 0.9.6 rdoc --version 4.0.0 test-unit --version 2.0.0.0
を直せってエラーになった
最近のコメント