大神论坛

找回密码
快速注册
查看: 215 | 回复: 0

[源码] 有道云笔记文件 永久直链解析(无需服务器) 附.NET源码

主题

帖子

0

积分

初入江湖

UID
655
积分
0
精华
威望
0 点
违规
大神币
68 枚
注册时间
2023-10-14 10:45
发表于 2023-12-02 14:28
本帖最后由 Mint_Grass 于 2023-12-02 14:28 编辑

主要是想学习一下技术并看看原理,原来并不复杂。
主要可以用于软件分发,版本更新。相当于一个免费的服务器吧,再使用短地址来生成一下短地址,那是非常完美了。

1.有道云笔记分享地址:https://note.youdao.com/s/cusiy8WX
2.使用本工具解析的地址:http://note.youdao.com/yws/api/personal/file/WEBfb1d035ffc78cb76efe912ac254fcb0b?method=download&inline=true&shareKey=bc6ee9ebf60cba8c2bd793ad30dec7f1
3.使用新浪短网址生成的地址:https://dwz.win/a6ZP

新浪短网址 可以在这个地址生成:新浪短网址 短网址生成 网址缩短服务 - 短网址 (sina.lt)

觉着不错可以给个免费的评分,谢谢。

工具在这个文件夹下,自己也可以编译。

Public Class Form1

Private Sub DownText(strUrl As String)
Dim csStopwatch As New Stopwatch
strUrl = GetHttpResutl(strUrl)
Dim strPattern As String = "id=(.*?)&type="
Dim match As Match = Regex.Match(strUrl, strPattern)
If (match.Success) Then
Dim strID As String = match.Groups(0).Value.Replace("id=", "").Replace("&type=", "")
strUrl = $"http://note.youdao.com/yws/public/note/{strID}?editorType=0&cstk=cGtjFpHb"
Dim jsonResult As String = GetHttpResutl(strUrl, False)
Dim csRootobject As Rootobject = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Rootobject)(jsonResult)
Dim strP As String = csRootobject.p.Replace("/", "")
TextBox2.Text = $"http://note.youdao.com/yws/api/personal/file/{strP}?method=download&inline=true&shareKey={strID}"
Else
MsgBox("分享链接无法解析", MsgBoxStyle.OkOnly, "提示")
End If
csStopwatch.Stop()
End Sub

Private Function GetHttpResutl(strUrl As String, Optional ByVal bolUrl As Boolean = True) As String

Using httpClient As New HttpClient()
Try
' 发起 GET 请求
Dim response As HttpResponseMessage = httpClient.GetAsync(strUrl).Result
' 确保请求成功
response.EnsureSuccessStatusCode()
' 读取 JSON 数据
If bolUrl Then
Return response.RequestMessage.RequestUri.ToString
Else
Return response.Content.ReadAsStringAsync().Result
End If
Catch ex As HttpRequestException
MsgBox($"发生 HTTP 请求错误: {ex.Message}", MsgBoxStyle.OkOnly, "提示")
Return ""
End Try
End Using
End Function



Private Sub Btn_JX_Click(sender As Object, e As EventArgs) Handles Btn_JX.Click
TextBox2.Text = String.Empty
DownText(txt_Url.Text)
End Sub


End Class




Public Class Rootobject
Public Property p As String
Public Property ct As Integer
Public Property su As Object
Public Property pr As Integer
Public Property au As Object
Public Property pv As Integer
Public Property mt As Integer
Public Property sz As Integer
Public Property domain As Integer
Public Property tl As String
Public Property isFinanceNote As Boolean
End Class


返回顶部