Reputation: 351
I am building a website, which categorizes IT problems. How can I get the content of all tags used on Stack Overflow?
I need to use the same tagging feature with the same content, but separately.
How can I extract the content of all tags? (It should be a couple of thousand.)
Upvotes: 18
Views: 6036
Reputation: 648
I developed upon andy's answer and gathered up each tag's synonyms as well:
select e.id,
count(t.tagName),
string_agg(TagSynonyms.SourceTagName, ',') as synonyms,
t.tagName,
e.body as 'Excerpt',
w.body as 'WikiBody'
from tags t
left join Posts e
on t.ExcerptPostId = e.Id
left join Posts w
on t.WikiPostId = w.Id
left join TagSynonyms
on TagSynonyms.TargetTagName = t.tagName
group by t.tagName, e.body, w.body, e.id
order by count(t.tagName) desc
The link is here.
Upvotes: 6
Reputation: 50550
You can utilize the Stack Exchange Data Explorer for gathering this type of information.
The query below will pull all tags, their excerpts and their wiki content:
select
t.tagName,
e.body as 'Excerpt',
w.body as 'WikiBody'
from tags t
left join Posts e
on t.ExcerptPostId = e.Id
left join Posts w
on t.WikiPostId = w.Id
order by t.tagName
At the time of this post, this returns 42,553 rows.
Note that not all tags have excerpts or wiki content.
Upvotes: 25