如何基于搜索查询从stackoverflow API获取问题列表? [英] How to get a list of questions from stackoverflow API based on search query?
问题描述
我对获取基于标签或搜索查询的问题列表感兴趣.我给你举个例子.
I am interested in the getting a list of the question based on a tag or a search query. I will give you an example.
因此,如果我将搜索关键字用作"ipv4",它应该给我大量与ipv4相关的问题.我要做的就是以列表或数组的形式获取问题(标题),以便对其进行处理.
So If I use the search keyword as "ipv4", it should give me a big list of questions related to ipv4. All I want to do is get the questions (title) as a list or an array so that I can do some processing on it.
推荐答案
您可以使用 questions/
路线.在此调用中,您会将您感兴趣的标记传递给tagged
参数(以分号(;
)分隔).
You can get this information utilizing the questions/
route. In this call, you will pass the tag(s) you are interested in to the tagged
parameter (separated by a semicolon (;
)).
要限制返回给具有一组标签的问题,请使用带有分号分隔的标签列表的tagd参数.这是一个和约束,传递
tagged=c;java
只会返回同时带有两个标记的那些问题.因此,传递超过5个标签将始终返回零结果.
To constrain questions returned to those with a set of tags, use the tagged parameter with a semi-colon delimited list of tags. This is an and constraint, passing
tagged=c;java
will return only those questions with both tags. As such, passing more than 5 tags will always return zero results.
对于您的特定问题(搜索ipv4
),您可以以此为起点:
For your specific question (searching for ipv4
), you can utilize this as a starting point:
http://api.stackexchange.com/docs/questions#order=desc&sort=activity&tagged=ipv4&filter=!BHMIbze0EPheMk572h0ktETsgnphhU&site=stackoverflow&run=true
filter
是可选的,但是我去除了一些默认字段,以提供一个较小的示例.上面的链接返回如下所示的条目:
The filter
is optional, but I've stripped out some of the default fields to present a smaller example. The link above returns entries that look like this:
"items": [
{
"tags": [
"ruby-on-rails",
"ipv4",
"geokit"
],
"link": "http://stackoverflow.com/questions/29460004/rails-geokit-incorrectly-converting-ipv4-address-to-latitude-and-longitude",
"title": "Rails: Geokit incorrectly converting IPv4 address to latitude and longitude"
},
{
"tags": [
"networking",
"ip",
"ipv4",
"maxmind",
"cidr"
],
"link": "http://stackoverflow.com/questions/28358851/merging-of-multiple-ipv4-address-blocks-on-the-basis-of-their-country-region",
"title": "merging of multiple IPv4 address blocks on the basis of their country region"
},
...
}
这篇关于如何基于搜索查询从stackoverflow API获取问题列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!