我想创建一个网页,给定两个 reddit 用户名及其密码,将 user2 订阅到 user1 订阅的所有 subreddits。所以我需要:
- 获取 user1 订阅的 subreddits。
- 为 user2 订阅这些 reddit
我有使用 PHP 的经验,但我没有抓取经验(尤其是当用户必须登录时)以及提交将用户“订阅”到 subreddit 所需的信息类型。有人对如何做到这一点有任何想法吗?
问候,
蒂姆
我想创建一个网页,给定两个 reddit 用户名及其密码,将 user2 订阅到 user1 订阅的所有 subreddits。所以我需要:
我有使用 PHP 的经验,但我没有抓取经验(尤其是当用户必须登录时)以及提交将用户“订阅”到 subreddit 所需的信息类型。有人对如何做到这一点有任何想法吗?
问候,
蒂姆
假设这不违反 reddits 的服务条款,使用cURL登录,可能很容易regex获得必要的信息。从那里可以检查 reddit 如何订阅收藏夹以及导航到正确的 url 或发布表单数据。
只要不违反 reddit 服务条款,我将其称为中级任务。
开源产品TestPlan非常擅长这些事情。使用一种简单的语言,您可以使用一个用户登录该站点,获取 subreddits 的名称,然后以其他用户身份登录以订阅组。
例如,如果您只想要顶部条目的标题,您可以使用以下代码:
GotoURL http://www.reddit.com/top/
set %Topics% as response //p[@class='title']
foreach %Topic% in %Topics%
set %Title% as selectIn %Topic% string(.)
Notice %Title%
end
产生这样的输出:
00000000-00 GOTOURL http://www.reddit.com/top/
00000001-00 NOTICE LEGAL DVD vs. PIRATED COPY (i.imgur.com)
00000002-00 NOTICE Don't just shorten your URL, make it suspicious and frightening. - ShadyURL (shadyurl.com)
00000003-00 NOTICE HOLY CRAP! IS THAT A ROOM FOR RENT ON MY CRAIGSLIST??!?!? (houston.craigslist.org)
00000004-00 NOTICE Years from now when our children ask us, "What did we do after 9/11?" we shall explain it to them using this... (4gifs.com)
00000005-00 NOTICE TSA forces disabled boy to remove leg braces and walk through the metal detector. "I told him, 'This is overkill. He's 4 years old. I don't think he's a terrorist.' " (philly.com)
00000006-00 NOTICE This picture scares the shit out of me. (imgur.com)
00000007-00 NOTICE Civilization V Announced, in Development at Firaxis Games (hellforge.gameriot.com)
00000008-00 NOTICE I don't know, the price seems a little steep... [pic] (i.imgur.com)
00000009-00 NOTICE Reddit, last week we saw the depth of the ocean scaled relative to human size. I made a figure of the depth of the ocean accurately scaled to the width. It's really very shallow from this perspective. (i.imgur.com)