Hackpads are smart collaborative documents. .

Meng-Ying Tsai

715 days ago
Shu-Kai H Collecting data via API in a collaborative way
抓回來的資料可以放在  https://goo.gl/WAmUzJ
記得檔名可以辨識出組別
Vivienne C install.packages("Rfacebook")
 
Shu-Kai H RFacebook
 
鍾豪
  • 第一組
  • require(Rfacebook)
  • token = 'hihihaha'
Meng-Ying T
鍾豪
  • 是,我們用的是developer。但好像不能用searchFacebook, 所以我們是用getPage,是Rfacebook的另一個函數。
  • 我們用searchFacebook也失敗
Meng-Ying T
  • 噢噢,原來是這樣,太感謝了>///////<
鍾豪
  • posts <- searchFacebook(string = "upworthy", token, n = 500)
  • page = getPage("myudn", token, n=1000,since='2015/11/01', until='2015/12/09')
  • hhh <- page$message
  • grep('健保',hhh)
  • hhh[idx]
 
[1] "#陳建仁 :「陸生與外籍生一樣,都是來台灣接受高等教育的對象,因此陸生與外生都應該有健康保險,全世界的國家都是如此,也都有一定的配套與考量。」 #陸生 #健保 #宅編\n\n【2016大選特別報導】 goo.gl/9cfVj8"
[2] "囤藥當伴手禮... #健保 #陸配 #陸生"                                                                                                                                                                   
[3] "陸生納保案禮拜五送立法院,引起網友熱烈討論 #陸生納保 #健保"                                                                                                                                          
[4] "吳育昇:民進黨團如果反對表決,就是反對人權普世價值。\n\n【陸生納健保、陸配4年拿身分證 藍盼速修法】 goo.gl/U83TLr\n#吳育昇 #陸生 #健保 #人權 #立法院 #宅編
 
Hsu H
Mipanox C twitteR
library(twitteR)
cKey <- "Consumer Key (API Key)"
cSecret <- "Consumer Secret (API Secret)"
token <- "Access Token"
tokens <- "Access Token Secret"
 
setup_twitter_oauth(cKey,cSecret,token,tokens)
 
tweets <- searchTwitter("keywords", n =10)
 
Hsu H
  • 第四組
Eric C library(Rfacebook)
NOtoken <- "wheeeeeeee"
NOID <- "163253543730991"  # UDN,慎用!
 
page.all <- getPage(NOID, NOtoken, n = 10000, since = "2015/10/01", until = "2015/11/30", feed = FALSE)
 
page.all[grepl("健保", page.all$message), 3]
 
# 收工
 
Hsu H
Forsure W PHP 爬蟲
PHP 爬蟲,再將結果整理儲存到MySql
Weihang
  •  恨 ORCALE   MYSQL 越來越不open 了XD
Forsure W 詳細內容在github
 
------------------------------------------------------------------------------------------------------------------------------------
Meng-Ying T Rfacebook 爬蟲
詳細內容參見Github
  • 安裝
  • install.packages("Rfacebook")  
  • 抓public post
  • token <- "XXXXXXXXXXX"
  • posts <- searchFacebook(string = "upworthy", token, n = 500, 
  •                         since = "25 november 2015 00:00", until = "25 november 2015 23:59")
出現錯誤訊息 : 
  • Searching for posts was deprecated with version 2.0 of the Facebook Graph API.
  • For more details see ?searchFacebook
Meng-Ying T
  • Rfacebook的版本貌似太舊了呢QAQ"
 
Hsu H
Hsiao W 安裝
  • install.packages('twitteR')
  • install.packages('base64enc')
  • install.packages('httk')
  • install.packages('httpuv')
授權
  • setup_twitter_oauth('API Key', 'API Secret')
搜尋字串
  • searchTwitteR('陸生健保', n= 100)
Result
[[1]]
[1] "rugecedovyxu: 陸生納健保意見多 教育部:盼境外生一致 https://t.co/ABW0vemXrw"
Hsiao W
  • 只有一筆output
 
Weihang
  • 第八組
 
  • import json
  • import requests
  • r = requests.get(url)
 
 

Contact Support



Please check out our How-to Guide and FAQ first to see if your question is already answered! :)

If you have a feature request, please add it to this pad. Thanks!


Log in