-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0190915
commit c2f8c10
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Bilibili-AvToBv | ||
=== | ||
一个爬取bilibili用户名和简介的小玩意~开源协议为WTFPL。当前版本为v1.0.0。 | ||
|
||
食用方法 | ||
--- | ||
* 打开exe程序,按照提示进行输入。 |
Binary file added
BIN
+30.5 KB
src/Bilibili-UserNameAndIntroduction/.vs/Bilibili-UserNameAndIntroduction/v16/.suo
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
src/Bilibili-UserNameAndIntroduction/Bilibili-UserNameAndIntroduction.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30011.22 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bilibili-UserNameAndIntroduction", "Bilibili-UserNameAndIntroduction\Bilibili-UserNameAndIntroduction.vbproj", "{626D2FBA-3219-47AB-9B2F-E8A7D7E0293D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{626D2FBA-3219-47AB-9B2F-E8A7D7E0293D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{626D2FBA-3219-47AB-9B2F-E8A7D7E0293D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{626D2FBA-3219-47AB-9B2F-E8A7D7E0293D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{626D2FBA-3219-47AB-9B2F-E8A7D7E0293D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {F6C74483-F933-4C03-B9F0-E51C8E27E191} | ||
EndGlobalSection | ||
EndGlobal |
9 changes: 9 additions & 0 deletions
9
...eAndIntroduction/Bilibili-UserNameAndIntroduction/Bilibili-UserNameAndIntroduction.vbproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>Bilibili_UserNameAndIntroduction</RootNamespace> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
48 changes: 48 additions & 0 deletions
48
src/Bilibili-UserNameAndIntroduction/Bilibili-UserNameAndIntroduction/Program.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Imports System.Net.Http | ||
Imports System.Text.RegularExpressions | ||
|
||
Module Program | ||
ReadOnly client As HttpClient = New HttpClient() | ||
Sub Main() | ||
While True | ||
' 输入uid | ||
Console.Write("UID:") | ||
Dim uid As String = Console.ReadLine() | ||
Dim html | ||
' 获取html | ||
Try | ||
html = GetHtml($"https://space.bilibili.com/{uid}") | ||
Catch | ||
Console.WriteLine("未找到该用户") | ||
Continue While | ||
End Try | ||
' 使用正则表达式分析html | ||
Dim user = Regex.Match(html, "<meta name=""description"" content=""[^""]+""/>").Value | ||
' 截取字符串,获得结果 | ||
If user IsNot "" Then | ||
Dim userName = user.Substring(34, user.IndexOf(",") - 34) | ||
Console.WriteLine("该用户名称为:" + userName) | ||
If (user.Length - 68 - user.IndexOf(",") - 2) = 0 Then | ||
Console.WriteLine("该用户无简介") | ||
Else | ||
Dim introduction = user.Substring(user.IndexOf(",") + 1, user.Length - 68 - user.IndexOf(",") - 2) | ||
Console.WriteLine("该用户简介为:" + introduction) | ||
End If | ||
|
||
Else | ||
Console.WriteLine("未找到该用户") | ||
End If | ||
End While | ||
End Sub | ||
|
||
''' <summary> | ||
''' 获取html | ||
''' </summary> | ||
''' <param name="url">地址</param> | ||
''' <returns>html</returns> | ||
Function GetHtml(ByVal url As String) As String | ||
Dim response As HttpResponseMessage = client.GetAsync(url).Result | ||
response.EnsureSuccessStatusCode() | ||
Return response.Content.ReadAsStringAsync().Result | ||
End Function | ||
End Module |