Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Haceau-Zoac committed Aug 7, 2020
1 parent 0190915 commit c2f8c10
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bilibili-AvToBv
===
一个爬取bilibili用户名和简介的小玩意~开源协议为WTFPL。当前版本为v1.0.0。

食用方法
---
* 打开exe程序,按照提示进行输入。
Binary file not shown.
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
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>
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

0 comments on commit c2f8c10

Please sign in to comment.