标签: reddit

通过URL发布到Reddit

是否可以通过URL发布Reddit链接?

例如,Facebook可以做到

<a href="https://www.facebook.com/sharer/sharer.php?u=http://stackoverflow.com">
  Share Stackoverflow on your profile!
</a>
Run Code Online (Sandbox Code Playgroud)

Reddit是否有一个我可以点击共享URL的等效端点?

reddit

12
推荐指数
1
解决办法
1万
查看次数

从python中的特定reddit线程获取所有注释

官方的方式,

r = praw.Reddit('Comment Scraper 1.0 by u/_Daimon_ see '
                 'https://praw.readthedocs.org/en/latest/'
                 'pages/comment_parsing.html')
submission = r.get_submission(submission_id='11v36o')
submission.replace_more_comments(limit=None, threshold=0)
Run Code Online (Sandbox Code Playgroud)

非常慢.有没有办法加快速度?有人已经将每个reddit注释提取到数据库中,因此必须有一些方法可以更快地完成此操作.

python performance reddit praw

12
推荐指数
2
解决办法
8089
查看次数

有没有办法获得给定subreddit的所有帖子,而不仅仅是一个月以上的帖子?

有没有办法获得给定subreddit的所有帖子,而不仅仅是一个月以上的帖子?

例如,这是我们可以获得的IAmA subreddit帖子的"最后一页",http: //www.reddit.com/r/IAmA/?count = 900&limit = 100&after = t3_1k3tm1 ,显然这不是最后一页帖子页面.它不包括超过一个月的任何帖子.

api reddit web-crawler

10
推荐指数
1
解决办法
1万
查看次数

如何告诉Reddit忽略缩略图的Logo?

当用户从我的网站共享内容时,缩略图中出现的图像通常是网站的徽标而不是图像本身.

我怎么能告诉reddit忽略徽标?

我搜索了很多,并找到了如何指定reddit应该与og imagemeta标签一起使用的图像的答案,但我不能这样做,因为我的网站是UGC的一部分,这意味着我不知道每个图像的绝对URL是什么.

例如:reddit没有在链接帖子上拉刮图像

编辑:

这似乎不适合我.它适用于你的吗?

<script>
function img_find() {
    var imgs = document.getElementsByTagName("img");
    var imgSrcs = [];

    for (var i = 0; i < imgs.length; i++) {
        imgSrcs.push(imgs[i].src);
    }

    return imgSrcs;
}var result = img_find();
$("meta[property='og:image']").attr("content", result[1]);
</script>
Run Code Online (Sandbox Code Playgroud)

html javascript facebook reddit facebook-opengraph

10
推荐指数
1
解决办法
315
查看次数

Reddit中使用的Cassandra数据库模式是什么?

Reddit目前正在将其数据库从PosgreSQL迁移到Apache Cassandra.有人知道Reddit在Cassandra中使用了什么数据库模式吗?

reddit cassandra database-schema

9
推荐指数
1
解决办法
2881
查看次数

urllib2 HTTP错误429

所以我有一个子reddits列表,我正在使用urllib打开它们.当我经历他们时,urllib最终失败了:

urllib2.HTTPError: HTTP Error 429: Unknown
Run Code Online (Sandbox Code Playgroud)

做一些研究我发现reddit通过IP限制了对服务器的请求数量:

每两秒钟发出一次请求.突发请求有一些限制,但要保持理智.一般情况下,一分钟内保持不超过30个请求.

所以我想我time.sleep()每隔10秒就会将请求限制在一个页面上.这最终也失败了.

上面的引用是从reddit API页面中获取的.我没有使用reddit API.在这一点上,我在想两件事.该限制仅适用于reddit API或urllib也有限制.

有谁知道这两件事中的哪一件?或者我如何解决这个问题?

python urllib2 reddit http-status-code-429

9
推荐指数
2
解决办法
2万
查看次数

无法刷新Reddit OAuth 2.0访问令牌

我无法刷新Reddit访问令牌.

当我发送以下请求时 https://ssl.reddit.com/api/v1/access_token

Content-Type: application/x-www-form-urlencoded
Authorization: #####
client_secret=#####&grant_type=refresh_token&client_id=#####&refresh_token=#####
Run Code Online (Sandbox Code Playgroud)

我得到状态,200但内容是{"error": "invalid_request"}.

根据OAuth 2.0规范Reddit规范,我做的一切都是正确的.

我也没试过client_id并且client_secret得到了相同的结果.

我错过了什么吗?

reddit oauth-2.0

9
推荐指数
1
解决办法
2489
查看次数

Python中包含一百万个元素的列表会占用多少内存?

根据redditmetrics.com的数据,Reddit上有超过一百万个子评价.

我写了一个脚本,反复查询这个Reddit API端点,直到所有的subreddit都存储在一个数组中,all_subs:

all_subs = []
for sub in <repeated request here>:
    all_subs.append({"name": display_name, "subscribers": subscriber_count})
Run Code Online (Sandbox Code Playgroud)

该脚本已经运行了近十个小时,大约已经完成了一半(每三个或四个请求就会受到速率限制).当它完成后,我期待一个像这样的数组:

[
    { "name": "AskReddit", "subscribers", 16751677 },
    { "name": "news", "subscribers", 13860169 },
    { "name": "politics", "subscribers", 3350326 },
    ... # plus one million more entries
]
Run Code Online (Sandbox Code Playgroud)

这个列表占用的内存空间大约是多少?

python memory arrays reddit

9
推荐指数
1
解决办法
5894
查看次数

从Google App Engine调用Reddit api时出现错误429

我已经在Google App Engine上运行了一个多月的cron工作,没有任何问题.这项工作做了很多事情,一个是它使用urllib2来调用从Reddit以及其他一些站点检索json响应.大约两周前,我开始在调用Reddit时看到错误,但在调用其他站点时没有错误.我收到的错误是HTTP错误429.

我尝试在Google App Engine之外执行相同的代码并且没有任何问题.我尝试使用urlFetch,但收到相同的错误.

使用应用程序引擎的交互式shell时,您可以看到错误,其中包含以下代码.

import urllib2
data = urllib2.urlopen('http://www.reddit.com/r/Music/.json', timeout=60)
Run Code Online (Sandbox Code Playgroud)

编辑:不确定为什么它总是失败对​​我而不是别人.这是我收到的错误:

>>> import urllib2
>>> data = urllib2.urlopen('http://www.reddit.com/r/Music/.json', timeout=60)
Traceback (most recent call last):
  File "/base/data/home/apps/s~shell-27/1.356011914885973647/shell.py", line 267, in get
    exec compiled in statement_module.__dict__
  File "<string>", line 1, in <module>
  File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 400, in open
    response = meth(req, response)
  File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 513, in http_response
    'http', request, response, code, msg, hdrs)
  File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line …
Run Code Online (Sandbox Code Playgroud)

python google-app-engine reddit

8
推荐指数
1
解决办法
8016
查看次数

ValueError:除非使用--disable-jpeg,aborting明确禁用,否则jpeg是必需的

我尝试在12.04 ubuntu服务器上安装reddit,但是我收到错误

请看下面终端的线路.请帮我修理一下.我在ff行" sudo python setup.py develop " 之后得到这个错误

我已经使用PPA安装了所有必需的依赖项

Cannot find Cython. Skipping Cython build.
Cannot find Baseplate. Skipping Thrift build.
running develop
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
running egg_info
writing requirements to r2.egg-info/requires.txt
writing r2.egg-info/PKG-INFO
writing top-level names to r2.egg-info/top_level.txt
writing dependency_links to r2.egg-info/dependency_links.txt
writing entry points to r2.egg-info/entry_points.txt
reading manifest file 'r2.egg-info/SOURCES.txt'
writing manifest file 'r2.egg-info/SOURCES.txt'
running build_ext
copying build/lib.linux-x86_64-2.7/Cfilters.so -> 
Creating …
Run Code Online (Sandbox Code Playgroud)

python reddit ubuntu-12.04 pillow server

8
推荐指数
1
解决办法
7431
查看次数