ruby – 如何刮_private_ google组?

我想删除一个私人谷歌组的讨论列表.这是一个页面列表,我可能会再次这样做脚本听起来像去的方式.

由于这是一个私人团体,我需要首先登录我的谷歌帐户.
不幸的是,我无法使用wget或ruby Net :: HTTP进行登录.令人惊讶的是,Google团队无法使用Client Login interface,所以所有的代码示例都是无用的.

我的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

这是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

解决方法

你试过 mechanize为ruby吗?
机械化库用于自动化与网站的交互;您可以登录到Google,并浏览您的私人谷歌组,保存您所需要的.

Here一个用于抓取邮件的机械化示例.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...