Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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是一个用于抓取邮件的机械化示例.

大佬总结

以上是大佬教程为你收集整理的ruby – 如何刮_private_ google组?全部内容,希望文章能够帮你解决ruby – 如何刮_private_ google组?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。