-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Showing
7 changed files
with
186 additions
and
23 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
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
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
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,44 @@ | ||
using AngleSharp.Dom; | ||
using ArchiSteamFarm.Web.Responses; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace ASFEnhance.Friend | ||
{ | ||
internal static partial class HtmlParser | ||
{ | ||
|
||
[GeneratedRegex("\"steamid\":\"(\\d+)\"")] | ||
private static partial Regex MatchSteamId(); | ||
|
||
/// <summary> | ||
/// 解析个人资料页面 | ||
/// </summary> | ||
/// <param name="response"></param> | ||
/// <returns></returns> | ||
internal static ulong? ParseProfilePage(HtmlDocumentResponse? response) | ||
{ | ||
if (response?.Content == null) | ||
{ | ||
return null; | ||
} | ||
|
||
var scriptNode = response.Content.QuerySelector<IElement>("#responsive_page_template_content>script"); | ||
var text = scriptNode?.Text(); | ||
|
||
if (!string.IsNullOrEmpty(text)) | ||
{ | ||
Regex regex = MatchSteamId(); | ||
|
||
var match = regex.Match(text); | ||
if (match.Success) | ||
{ | ||
var strId = match.Groups[1].Value; | ||
return ulong.TryParse(strId, out ulong steamId) ? steamId : null; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
} | ||
} |
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
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
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