started wikidata component
This commit is contained in:
parent
68e844251d
commit
4def11c2f9
5 changed files with 51 additions and 0 deletions
10
src/BirdsiteLive.Wikidata/BirdsiteLive.Wikidata.csproj
Normal file
10
src/BirdsiteLive.Wikidata/BirdsiteLive.Wikidata.csproj
Normal file
|
@ -0,0 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
23
src/BirdsiteLive.Wikidata/Program.cs
Normal file
23
src/BirdsiteLive.Wikidata/Program.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
||||
var client = new HttpClient();
|
||||
string query = new StreamReader("query.sparql").ReadToEnd();
|
||||
|
||||
client.DefaultRequestHeaders.Add("Accept", "text/csv");
|
||||
client.DefaultRequestHeaders.Add("User-Agent", "BirdMakeup/1.0 (https://bird.makeup; coolbot@example.org) BirdMakeup/1.0");
|
||||
var response = await client.GetAsync($"https://query.wikidata.org/sparql?query={Uri.EscapeDataString(query)}");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Console.WriteLine(content);
|
||||
|
||||
foreach (string n in content.Split("\n"))
|
||||
{
|
||||
var s = n.Split(",");
|
||||
Console.WriteLine(s[0]);
|
||||
}
|
||||
|
2
src/BirdsiteLive.Wikidata/README.md
Normal file
2
src/BirdsiteLive.Wikidata/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Wikidata service
|
||||
|
9
src/BirdsiteLive.Wikidata/query.sparql
Normal file
9
src/BirdsiteLive.Wikidata/query.sparql
Normal file
|
@ -0,0 +1,9 @@
|
|||
#Cats
|
||||
SELECT ?item ?username ?username2 ?linkcount ?itemLabel
|
||||
WHERE
|
||||
{
|
||||
?item wdt:P2002 ?username.
|
||||
?item wdt:P4033 ?username2.
|
||||
?item wikibase:sitelinks ?linkcount .
|
||||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
|
||||
} ORDER BY DESC(?linkcount) LIMIT 5000
|
|
@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BirdsiteLive.Common.Tests",
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BirdsiteLive.Twitter.Tests", "Tests\BirdsiteLive.Twitter.Tests\BirdsiteLive.Twitter.Tests.csproj", "{2DFA0BFD-88F5-4434-A6E3-C93B5750E88C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BirdsiteLive.Wikidata", "BirdsiteLive.Wikidata\BirdsiteLive.Wikidata.csproj", "{EAB43087-359C-46BD-8796-5F7D9B473B39}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -131,6 +133,10 @@ Global
|
|||
{2DFA0BFD-88F5-4434-A6E3-C93B5750E88C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2DFA0BFD-88F5-4434-A6E3-C93B5750E88C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2DFA0BFD-88F5-4434-A6E3-C93B5750E88C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EAB43087-359C-46BD-8796-5F7D9B473B39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EAB43087-359C-46BD-8796-5F7D9B473B39}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EAB43087-359C-46BD-8796-5F7D9B473B39}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EAB43087-359C-46BD-8796-5F7D9B473B39}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -154,6 +160,7 @@ Global
|
|||
{0A311BF3-4FD9-4303-940A-A3778890561C} = {A32D3458-09D0-4E0A-BA4B-8C411B816B94}
|
||||
{C69F7582-6050-44DC-BAAB-7C8F0BDA525C} = {A32D3458-09D0-4E0A-BA4B-8C411B816B94}
|
||||
{2DFA0BFD-88F5-4434-A6E3-C93B5750E88C} = {A32D3458-09D0-4E0A-BA4B-8C411B816B94}
|
||||
{EAB43087-359C-46BD-8796-5F7D9B473B39} = {DA3C160C-4811-4E26-A5AD-42B81FAF2D7C}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {69E8DCAD-4C37-4010-858F-5F94E6FBABCE}
|
||||
|
|
Loading…
Add table
Reference in a new issue