是否可以通过 API 获取用户个人资料信息,例如 GitHub、Twitter 帐户名称?此信息在用户个人资料页面中可见,我想知道是否有办法以编程方式访问此信息。
给定一系列关键字,例如"Python最佳实践",我想获得包含关键字的前10个Stack Overflow问题,按相关性(?)排序,比如Python脚本.我的目标是最终得到一个元组列表(标题,URL).
我怎么能做到这一点?您会考虑查询Google吗?(你会怎么用Python做的?)
我在想,有没有什么方法可以通过我的登录我的stackoverflow.com帐户python code.
有什么stackoverflow-pythonAPI我可以通过它完成上述任务.
我在问这里之前用Google搜索,但是找不到任何API,也没有任何Hello World使用python的例子.
如何使用Matlab从StackExchange API访问数据?
天真
sitedata = urlread('http://api.stackoverflow.com/1.1/questions?tagged=matlab')
Run Code Online (Sandbox Code Playgroud)
因为数据被压缩而失败.但是,当我将其写入文件(使用fprintf(fileID,'%s',sitedata))时,我得到一个无法解压缩的zip文件.
我正在尝试从 stackexchange api 获取一些 json 数据。接收 OAuth 代码和访问令牌工作正常。但是当调用实际的数据获取端点时,响应看起来确实很奇怪。可能是编码或类似的。
\n\n该请求如下所示:
\n\nvar client = requestjson.newClient(\'https://api.stackexchange.com\');\n client.get("/2.2/me/comments?order=desc&sort=creation&site=stackoverflow&access_token="+myToken+"&key="+key, function(err, res, body) {\n console.log(body);\n })\nRun Code Online (Sandbox Code Playgroud)\n\n然后响应正文如下所示:
\n\ni\xef\xbf\xbd)\xef\xbf\xbd)QEJ\xef\xbf\xbda\xef\xbf\xbd\xef\xbf\xbdMl\xef\xbf\xbdd4\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd20\xef\xbf\xbdc\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdM\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd]\xef\xbf\xbdv5/AZ\xef\xbf\xbdm\xef\xbf\xbd\xef\xbf\xbdz \xef\xbf\xbdC\xef\xbf\xbd\xef\xbf\xbd`\xef\xbf\xbd~\xef\xbf\xbd\xef\xbf\xbd\xef\xb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bdX\xef\xbf\xbd9X~\xef\xbf\xbd\xef\xbf\xbdg\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xce\x81YrVY\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdB\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdX1#\xef\xbf\xbd`E\nRun Code Online (Sandbox Code Playgroud)\n\n我已经尝试过JSON.parse,但它在控制台中抛出错误。
我需要从特定的堆栈交换站点获取数据.
我怎样才能最有效地完成这项工作?我可以使用某种API吗?我需要将它们保存到某种数据库中.
我正在尝试从 StackApi 获取问题和答案来训练深度学习模型。我有一个问题,我不明白如何使用自定义过滤器,所以我只能得到问题的正文。
\n这是我的代码:
\nfrom stackapi import StackAPI\nimport torch\nimport torch.nn as nn\n\nSITE = StackAPI('stackoverflow')\nSITE.max_pages=1\nSITE.page_size=1\ndata = SITE.fetch('questions', tagged='python',filter = '!*SU8CGYZitCB.D*(BDVIficKj7nFMLLDij64nVID)N9aK3GmR9kT4IzT*5iO_1y3iZ)6W.G*', sort = 'votes')\nfor quest in data['items']:\n question = quest['title']\n print(question)\n question_id = quest['question_id']\n print (question_id)\n dataAnswer = SITE.fetch('questions/{ids}/answers', ids=[question_id], filter='withbody')\n print(dataAnswer)\nRun Code Online (Sandbox Code Playgroud)\n我的 dataAnswer 结果:
\n{'backoff': 0, 'has_more': True, 'page': 1, 'quota_max': 300, 'quota_remaining': 300, 'total': 0, 'items': [{'owner': {'reputation': 404, 'user_id': 11182732, 'user_type': 'registered', 'profile_image': 'https://lh6.googleusercontent.com/-F2a9OP4yGHc/AAAAAAAAAAI/AAAAAAAADVo/Mn4oVgim-m8/photo.jpg?sz=128', 'display_name': 'Aditya patil', 'link': '/sf/users/782791271/'}, 'is_accepted': False, 'score': 8, 'last_activity_date': 1609856797, …Run Code Online (Sandbox Code Playgroud) 我在“Main”类中声明了一个名为“context2”的变量。但我无法在函数“Main_Load”中使用该变量。我究竟做错了什么 ?
using System;
using System.Windows.Forms;
using Soapi;
using Soapi.Domain;
namespace SO_Console_Client
{
public partial class Main : Form
{
const string apiKey = "*************";
var context2 = new ApiContext(apiKey).Initialize(false);
public Main(String GravatarURL, User user)
{
InitializeComponent();
pictureBox1.Load(GravatarURL); //Loads the Gravatar image from the url
//set the reputation details
lblRep.Text = String.Format("Reputation: {0}", user.Reputation);
//Sets the badge details
lblBadge.Text = String.Format("Badges: gold={0} silver={1} bronze={2}", user.BadgeCounts.Gold, user.BadgeCounts.Silver, user.BadgeCounts.Bronze);
groupBox1.Text = user.DisplayName.ToString();
}
private void Main_Load(object sender, EventArgs e)
{
Soapi.Queries.QuestionsUnansweredQuery query …Run Code Online (Sandbox Code Playgroud) 我正在使用stackAPI Python 包装器与 stackexchange api 进行交互。我正在尝试获取高于投票计数阈值的最热门问题;对于每个问题,超过一定票数的最佳答案。
SITE = StackAPI("stackoverflow")
SITE.max_pages=2
SITE.page_size=100
questions = SITE.fetch('questions', min=10, sort='votes')
for quest in questions['items']:
if 'title' not in quest: continue
quest_id = quest['question_id']
title = quest['title']
tags = []
if 'tags' in quest:
tags = quest['tags']
#body = quest['body']
body = ""
if 'body' in quest:
body = quest['body']
answers = SITE.fetch('answers', id=[quest_id],min=10, sort='votes')
for answer in answers['items']:
_stuck here_
Run Code Online (Sandbox Code Playgroud)
这就是我陷入困境的地方,如何获取上述 Question_id 的答案,此查询返回一些随机的answer_ids。如何获取question-< answers
我正在尝试使用此PHP访问Stack Overflow上的最新注释列表:
<?php
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
echo do_post_request("https://api.stackexchange.com/2.1/comments?order=desc&sort=creation&site=stackoverflow", "");
?>
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它时,我收到此错误消息:
$ php index.php
PHP Notice: …Run Code Online (Sandbox Code Playgroud) python ×5
.net ×1
c# ×1
fatal-error ×1
http ×1
javascript ×1
json ×1
matlab ×1
node.js ×1
php ×1
post ×1
python-2.7 ×1
scrapy ×1
scripting ×1
search ×1