一个命令行和编程接口,可以连接到各种社会共享计数端点。
socialshares的Python项目详细描述
访问社交共享的命令行实用程序和python库 对特定URL计数。
注意:很遗憾,此实用程序不再用于获取 tweet和retweet很重要,因为twitter已经删除了这个api 依赖的功能。Facebook和其他平台仍然有效。
用法
Usage: socialshares <url> [<platforms>...] [options] Options: -h, --help Show this screen. -p, --plain Plain output. -r <attempts>, --retry <attempts> Retry fetching up to <attempt> times [default: 1] -e, --exit Exit with an error code when not all counts could be fetched.
一些示例:
# fetch count for all supported platforms, # try again once (the default) for platforms that fail $ socialshares http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ # fetch only facebook $ socialshares http://www.theguardian.com/politics facebook --retry 2
支持的平台
Platform | Description |
---|---|
facebook shares and comments | |
linkedin shares | |
google +1’s | |
pinterest pins | |
reddit ups and downs (summed across posts) |
平台并行获取并重试(默认为一次)。如果没有 指定平台,只返回facebook和twitter。
不支持的平台
不幸的是,下面的API不再存在,并且已被删除 从界面。
Platform | Description |
---|---|
twitter tweets and retweets containing the URL | |
facebookfql | facebook likes, shares and comments |
输出
默认情况下,socialsharesoutputs json:
{"reddit":{"downs":0,"ups":6},"google":20,"facebook":1498,"twitter":300,"pinterest":1}
如果希望使用空格分隔的输出,请使用--plain标志。
$ socialshares http://www.theguardian.com/politics twitter
57
来自python的用法
importsocialsharescounts=socialshares.fetch(url,['facebook','pinterest'])
安装
pip install socialshares
# optionally, for asynchronous fetching
pip install grequests
如果requests_futures和 (对于python 2.x)futures 如果已安装,social-shares将使用这些软件包加速 通过访问 平行的。