gpt4 book ai didi

ruby - 如何抓取 _private_ 谷歌群组?

转载 作者:数据小太阳 更新时间:2023-10-29 06:46:47 40 4
gpt4 key购买 nike

我想抓取私有(private)谷歌群组的讨论列表。这是一个多页列表,稍后我可能不得不再次这样做,所以编写脚本听起来是个不错的选择。

由于这是一个私有(private)群组,我需要先登录我的谷歌帐户。不幸的是,我无法使用 wget 或 ruby​​ Net::HTTP 登录。令人惊讶的是,使用 Client Login interface 无法访问谷歌群组, 所以所有的代码示例都是无用的。

我的 ruby​​ 脚本嵌入在帖子的末尾。身份验证查询的响应是 200-OK,但响应 header 中没有 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 ?
Mechanize 库用于自动化与网站的交互;您可以登录到 google 并浏览您的私有(private) google 群组,保存您需要的内容。

Here mechanize 用于 gmail 抓取的示例。

关于ruby - 如何抓取 _private_ 谷歌群组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2565843/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com