如何抓一个_private_谷歌组?

Joh*_*ohn 10 ruby authentication screen-scraping wget google-groups

我想抓一个私人谷歌小组的讨论列表.这是一个多页面列表,我可能会在以后再次这样做,所以脚本听起来像是要走的路.

由于这是一个私人群组,我需要先登录我的Google帐户.不幸的是我无法使用wget或ruby Net :: HTTP登录.令人惊讶的是,使用客户端登录界面无法访问Google群组,因此所有代码示例都无用.

我的ruby脚本嵌入在帖子的末尾.对身份验证查询的响应是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='john@gmail.com'
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
Run Code Online (Sandbox Code Playgroud)

这是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=john@gmail.com&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
Run Code Online (Sandbox Code Playgroud)

sys*_*out 6

你试过机械化红宝石吗?
Mechanize库用于自动与网站交互; 您可以登录谷歌并浏览您的私人谷歌组保存您需要的.

这里是一个使用mechanize进行gmail抓取的示例.