<div class="playerAvatarAutoSizeInner">
<div class="profile_avatar_frame">
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png">
</div>
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif">
</div>
<div class="playerAvatarAutoSizeInner">
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/avatars/0c/0c82230c58063b3a7f1beec38528afb0613855be_full.jpg">
</div>
Sub AppStart (Args() As String)
Dim s As String = $"<div class="playerAvatarAutoSizeInner">
<div class="profile_avatar_frame">
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png">
</div>
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif">
</div>"$
Dim parser As MiniHtmlParser
parser.Initialize
Dim root As HtmlNode = parser.Parse(s)
Dim playerAvatarAutoSizeInner As HtmlNode = parser.FindNode(root, "div", parser.CreateHtmlAttribute("class", "playerAvatarAutoSizeInner"))
If playerAvatarAutoSizeInner.IsInitialized Then
Dim imgList As List = parser.FindDirectNodes(playerAvatarAutoSizeInner, "img", Null)
For Each img As HtmlNode In imgList
log(parser.GetAttributeValue(img, "src", ""))
Next
End If
End Sub
Dim parser As MiniHtmlParser
parser.Initialize
Dim root As HtmlNode = parser.Parse(SteamResponse)
Dim playerAvatarAutoSizeInner As HtmlNode = parser.FindNode(root, "div", parser.CreateHtmlAttribute("class", "playerAvatarAutoSizeInner"))
Log(HtmlParser.PrintNode(playerAvatarAutoSizeInner))
If playerAvatarAutoSizeInner.IsInitialized Then
Dim imgList As List = parser.FindDirectNodes(playerAvatarAutoSizeInner, "img", Null)
Log("# list size = "&imgList.Size)
For Each img As HtmlNode In imgList
Log("# link img inside list = "&parser.GetAttributeValue(img, "src", ""))
Next
End If
*** div ***
|class: playerAvatarAutoSizeInner|
*** text ***
|value: |
*** div ***
|class: profile_avatar_frame|
*** text ***
|value: |
*** img ***
|src: https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png|
*** text ***
|value: |
*** img ***
|src: https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif|
# list size = 1
# link img inside list = https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif
Sub AppStart (Args() As String)
Dim s As String = $"<div class="playerAvatarAutoSizeInner">
<div class="profile_avatar_frame">
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png">
</div>
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif">
</div>"$
parser.Initialize
Dim root As HtmlNode = parser.Parse(s)
Dim playerAvatarAutoSizeInner As HtmlNode = parser.FindNode(root, "div", parser.CreateHtmlAttribute("class", "playerAvatarAutoSizeInner"))
If playerAvatarAutoSizeInner.IsInitialized Then
Dim images As List
images.Initialize
LookForImgRecursive(playerAvatarAutoSizeInner, images)
Log(images)
End If
End Sub
Private Sub LookForImgRecursive (parent As HtmlNode, result As List)
If parent.Children.IsInitialized = False Then Return
For Each child As HtmlNode In parent.Children
If child.Name = "img" Then
result.Add(parser.GetAttributeValue(child, "src", ""))
Else
LookForImgRecursive(child, result)
End If
Next
End Sub
Dim s As String = $"<div class="playerAvatarAutoSizeInner">
<div class="profile_avatar_frame">
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png">
</div>
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif">
</div>"$
Dim pattern As String = "(http[^\s]+(jpg|svg|gif|jpeg|png|tiff)\b)"
Dim Matcher1 As Matcher = Regex.Matcher(pattern, s)
Do While Matcher1.Find
Log(Matcher1.Match)
Loop
test:
It only captures the images (src).
View attachment 124601B4X:Dim s As String = $"<div class="playerAvatarAutoSizeInner"> <div class="profile_avatar_frame"> <img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png"> </div> <img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif"> </div>"$ Dim pattern As String = "(http[^\s]+(jpg|svg|gif|jpeg|png|tiff)\b)" Dim Matcher1 As Matcher = Regex.Matcher(pattern, s) Do While Matcher1.Find Log(Matcher1.Match) Loop
I thought that you want to get the img tag that is a direct child of playerAvatarAutoSizeInner.
If you want to find all images inside this div then you should implement a simple recursive search:
B4X:Sub AppStart (Args() As String) Dim s As String = $"<div class="playerAvatarAutoSizeInner"> <div class="profile_avatar_frame"> <img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png"> </div> <img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif"> </div>"$ parser.Initialize Dim root As HtmlNode = parser.Parse(s) Dim playerAvatarAutoSizeInner As HtmlNode = parser.FindNode(root, "div", parser.CreateHtmlAttribute("class", "playerAvatarAutoSizeInner")) If playerAvatarAutoSizeInner.IsInitialized Then Dim images As List images.Initialize LookForImgRecursive(playerAvatarAutoSizeInner, images) Log(images) End If End Sub Private Sub LookForImgRecursive (parent As HtmlNode, result As List) If parent.Children.IsInitialized = False Then Return For Each child As HtmlNode In parent.Children If child.Name = "img" Then result.Add(parser.GetAttributeValue(child, "src", "")) Else LookForImgRecursive(child, result) End If Next End Sub
B4X:Sub AppStart (Args() As String) Dim s As String = $"<div class="playerAvatarAutoSizeInner"> <div class="profile_avatar_frame"> <img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png"> </div> <img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif"> </div>"$ Dim parser As MiniHtmlParser parser.Initialize Dim root As HtmlNode = parser.Parse(s) Dim playerAvatarAutoSizeInner As HtmlNode = parser.FindNode(root, "div", parser.CreateHtmlAttribute("class", "playerAvatarAutoSizeInner")) If playerAvatarAutoSizeInner.IsInitialized Then Dim imgList As List = parser.FindDirectNodes(playerAvatarAutoSizeInner, "img", Null) For Each img As HtmlNode In imgList log(parser.GetAttributeValue(img, "src", "")) Next End If End Sub
Dim s As String = $"<div class="playerAvatarAutoSizeInner">
<div class="profile_avatar_frame">
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png">
</div>
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif">
</div>"$
parser.Initialize
Dim root As HtmlNode = parser.Parse(s)
Dim playerAvatarAutoSizeInner As HtmlNode = parser.FindNode(root, "div", parser.CreateHtmlAttribute("class", "playerAvatarAutoSizeInner"))
If playerAvatarAutoSizeInner.IsInitialized Then
Dim img As HtmlNode = parser.FindNode(playerAvatarAutoSizeInner, "img", Null)
Log("returned = "&parser.GetAttributeValue(img, "src", ""))
End If
returned = https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png
Private Sub Button1_Click
Dim s As String = $"<div class="playerAvatarAutoSizeInner">
<div class="profile_avatar_frame">
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png">
</div>
<img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif">
</div>"$
Log(GetTagImage(GetTagClassDivHtml(s, "profile_avatar_frame")))
End Sub
Public Sub GetTagClassDivHtml(Html As String, Class As String) As String
Dim pattern As String = $"<div class=\"${Class}\">([^`]*?)<\/div>"$
Dim Matcher1 As Matcher = Regex.Matcher(pattern, Html)
Matcher1.Find
Return Matcher1.Match
End Sub
Public Sub GetTagImage(Html As String) As String
Dim pattern As String = "(http[^\s]+(jpg|svg|gif|jpeg|png|tiff)\b)"
Dim Matcher1 As Matcher = Regex.Matcher(pattern, Html)
Matcher1.Find
Return Matcher1.Match
End Sub
?
B4X:Private Sub Button1_Click Dim s As String = $"<div class="playerAvatarAutoSizeInner"> <div class="profile_avatar_frame"> <img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/465200/e89b3a70625c980c3d68869f5cdb1da9baa447f8.png"> </div> <img src="https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/1504020/397b0a7e2d1355bca92d3e803270f7947ba973aa.gif"> </div>"$ Log(GetTagImage(GetTagClassDivHtml(s, "profile_avatar_frame"))) End Sub Public Sub GetTagClassDivHtml(Html As String, Class As String) As String Dim pattern As String = $"<div class=\"${Class}\">([^`]*?)<\/div>"$ Dim Matcher1 As Matcher = Regex.Matcher(pattern, Html) Matcher1.Find Return Matcher1.Match End Sub Public Sub GetTagImage(Html As String) As String Dim pattern As String = "(http[^\s]+(jpg|svg|gif|jpeg|png|tiff)\b)" Dim Matcher1 As Matcher = Regex.Matcher(pattern, Html) Matcher1.Find Return Matcher1.Match End Sub
View attachment 124607
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?