This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<root> | |
<responses type="list"> | |
<item type="dict"> | |
<textAnnotations type="list"> | |
<item type="dict"> | |
<description type="str"> | |
首都圏の公務員就職率の上位20位 | |
設置 | |
私 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
import time | |
import requests # for slack | |
import json # for slack | |
#Phanttomjs Driverを入手 | |
browser = webdriver.PhantomJS('/usr/local/bin/phantomjs') # DO NOT FORGET to set path | |
#TODO set search query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
from requests_oauthlib import OAuth1Session # ライブラリ(1) | |
from bs4 import BeautifulSoup | |
from TwitterAPI import TwitterAPI | |
import requests | |
import tweepy | |
import os | |
# 各種キーをセット |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
''' | |
The following code is to help you play with Numpy, which is a library | |
that provides functions that are especially useful when you have to | |
work with large arrays and matrices of numeric data, like doing | |
matrix matrix multiplications. Also, Numpy is battle tested and | |
optimized so that it runs fast, much faster than if you were working | |
with Python lists directly. | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[1] 10回分試行する場合 | |
n = 10 | |
roll <- c("1","2","3","4","5","6") #サイコロの目を指定 | |
sample(roll, n, replace=T) #sample関数(後述) | |
table(sample(roll, n, replace=T)) #サイコロの目を、100回振ったものをtableで表示 | |
barplot(table(sample(roll, n, replace=T))) #それを棒グラフで表示 | |
#[2] 100回試行する場合 | |
n = 100 | |
roll <- c("1","2","3","4","5","6") #サイコロの目を指定 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import oauth | |
api = oauth.api | |
userid = "never_be_a_pm" #自分のツイッターアカウントのID | |
followers_id = api.followers_ids(userid) #自分のアカウントのフォロワーをすべて取得する | |
following_id = api.friends_ids(userid) #自分のアカウントのフォロイングをすべて取得する | |
for following in following_id: #自分がフォローしているユーザーだけ取得する | |
if following not in followers_id: #自分のフォローしているユーザーで、フォロワーに属さなユーザーを取得する | |
userfollowers = api.get_user(following).followers_count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import oauth | |
api = oauth.api | |
#自分のタイムラインのツイートを取得 | |
tweets = api.home_timeline(count = 30,include_rts = False) | |
#自分のタイムラインのツイートを30個取り出して、いいねする | |
for tweet in tweets: | |
try: | |
tweetid = tweet.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import oauth | |
api = oauth.api | |
q = "http://review-of-my-life.blogspot.jp/*" #自分のブログのURL *は正規表現?で、これから下のものはすべてということ | |
count = 10 #取得するツイートの数 | |
search_results = api.search(q=q, count=count) | |
for result in search_results: | |
username = result.user._json['screen_name'] | |
user_id = result.id #ツイートのstatusオブジェクトから、ツイートidを取得 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tweepyライブラリをインポート | |
import tweepy | |
# 各種キーをセット | |
CONSUMER_KEY = 'xxxxxxxx' | |
CONSUMER_SECRET = 'xxxxxxxx' | |
ACCESS_TOKEN = 'xxxxxxxx' | |
ACCESS_SECRET = 'xxxxxxxx' | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from selenium import webdriver | |
from urllib.parse import urljoin | |
import time | |
import csv | |
import codecs | |
#Phanttomjs Driverを入手 | |
browser = webdriver.PhantomJS() |
NewerOlder