我想抓取一個私人谷歌組的討論列表。這是一個多頁的列表,我可能會在稍後再次看到,所以腳本聽起來像是要走的路。如何刮取_private_ google羣組?
由於這是一個私人團體,我需要先登錄我的谷歌賬戶。 不幸的是,我無法設法使用wget或ruby Net :: HTTP進行登錄。奇怪的是谷歌組不能用Client Login interface訪問,所以所有的代碼示例都是無用的。
我的紅寶石腳本嵌入在帖子的末尾。對身份驗證查詢的響應是200-OK,但響應頭中沒有cookie,而主體包含消息「您的瀏覽器的cookie功能已關閉,請將其打開。」
我得到了與wget相同的輸出。看到這封郵件末尾的bash腳本。
我不知道如何解決這個問題。我錯過了什麼嗎?任何想法?
在此先感謝。
約翰
這裏是Ruby腳本:
# a ruby script
require 'net/https'
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
path = '/accounts/ServiceLoginAuth'
email='[email protected]'
password='topsecret'
# form inputs from the login page
data = "Email=#{email}&Passwd=#{password}&dsh=7379491738180116079&GALX=irvvmW0Z-zI"
headers = { 'Content-Type' => 'application/x-www-form-urlencoded',
'user-agent' => "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/6.0"}
# Post the request and print out the response to retrieve our authentication token
resp, data = http.post(path, data, headers)
puts resp
resp.each {|h, v| puts h+'='+v}
#warning: peer certificate won't be verified in this SSL session
這裏是bash腳本:
# A bash script for wget
CMD=""
CMD="$CMD --keep-session-cookies --save-cookies cookies.tmp"
CMD="$CMD --no-check-certificate"
CMD="$CMD --post-data='[email protected]&Passwd=topsecret&dsh=-8408553335275857936&GALX=irvvmW0Z-zI'"
CMD="$CMD --user-agent='Mozilla'"
CMD="$CMD https://www.google.com/accounts/ServiceLoginAuth"
echo $CMD
wget $CMD
wget --load-cookies="cookies.tmp" http://groups.google.com/group/mygroup/topics?tsc=2
嗨systempuntoout, 感謝您的回答。我不知道機械化。我設法登錄並颳了一些頁面,這很好。我稍後會分享這個腳本。再次感謝, 約翰 – John 2010-04-05 16:17:04
@約翰:後來多少? :-) – 2011-02-09 11:42:26
感謝您的鏈接!你可以基本上用irb和機械化物體衝浪網絡! – grinch 2012-08-14 02:31:04