Question get text data from website

Badi

Member
Joined
Mar 24, 2013
Messages
11
Programming Experience
1-3
I want to get text data from website in this way

7iRw8qU.png

gvEBRiH.png


i want only to get that text which i want not all elements.. from website

thanks
 
If it is what it looks like, then that is JSON data, and there exist several libraries that can be used to read such data structures, for example Json.NET.
 
Yes, that is Json data, which as I said can be read with that Json.Net library. You download and extract it, and add reference to \Bin\Net40\Newtonsoft.Json.dll.
Here's an example downloading the data from web, parsing it into JToken object, and getting some properties:
        Dim web As New Net.WebClient
        Dim text = web.DownloadString("http://www.paltalk.com/people/ws/profile/Jeff?pretty=true")

        Dim token = Newtonsoft.Json.Linq.JToken.Parse(text)
        Dim profile = token("Profile")
        Dim country = "Country: " & profile("country").ToString
        Dim content = "Content: " & profile("adContent").ToString
        Dim accdate = "Date: " & profile("dateAccountCreated").ToString

        Me.TextBox1.Text = String.Join(vbNewLine, {country, content, accdate})
 
thanks it works but i think i have problem if this profile doesn't exsit i got error Net framework, so is there any way to do without JSON Net ???
 
Last edited:
Yes, that is Json data, which as I said can be read with that Json.Net library. You download and extract it, and add reference to \Bin\Net40\Newtonsoft.Json.dll.
Here's an example downloading the data from web, parsing it into JToken object, and getting some properties:
        Dim web As New Net.WebClient
        Dim text = web.DownloadString("http://www.paltalk.com/people/ws/profile/Jeff?pretty=true")

        Dim token = Newtonsoft.Json.Linq.JToken.Parse(text)
        Dim profile = token("Profile")
        Dim country = "Country: " & profile("country").ToString
        Dim content = "Content: " & profile("adContent").ToString
        Dim accdate = "Date: " & profile("dateAccountCreated").ToString

        Me.TextBox1.Text = String.Join(vbNewLine, {country, content, accdate})


hi, but if in the Json data exist more than one value or text
e.g:
country: US
country: NL
country: UK

i used this one: Dim country = "Country: " & profile("country").ToString

but i'm getting error
 
May it returns a collection then?
 
ok
this https://commerce.paltalk.com/mpt/ws/mobile/getSubCatgDefsOut/2000?pretty=true

uMWCqGW.png

i tried this one

Dim token = Newtonsoft.Json.Linq.JToken.Parse(text)
Dim result = token("result")
Dim name = "Name: " & result("name").ToString
Dim last = "Last name: " & result("last").ToString
Dim gender = "Gender: " & result("gender").ToString
Dim location = "Location: " & result("location").ToString

Me.TextBox1.Text = String.Join(vbNewLine, {name, last, gender, location})
but didn't work can you help me with this thanks
 
Last edited:
"list" is a collection, and it has three items.
 
When you have selected the "list" token you can for example loop through all the items in that collection:
For Each item In listToken
    Dim s = item("name").ToString()

Next
 
i'm getting 2 errors sir can you send me completed code please

Dim web As New Net.WebClient
Dim text = web.DownloadString("URL")

Dim token = Newtonsoft.Json.Linq.JToken.Parse(text)
Dim result = token("result")
For Each item In list Token
Dim s = item("name").ToString()

Next


Me.TextBox1.Text = String.Join(vbNewLine, {country, content, accdate})


2 errors

1.
Expression expected.

2.Overload resolution failed because no accessible 'Join' is most specific for these arguments:
'Public Shared Function Join(Of Newtonsoft.Json.Linq.JToken)(separator As String, values As System.Collections.Generic.IEnumerable(Of Newtonsoft.Json.Linq.JToken)) As String': Not most specific.
'Public Shared Function Join(separator As String, ParamArray values() As Object) As String': Not most specific.
 
"result" is not a collection, is has a "list" token that is a collection. Are you not able to see the tree structure of the data?
For Each item In token("result")("list")
 
hmm now the things being complicated for me i can't understand i'm newbie in vb

can you write me all code from the begin please

sorry for disturbing you..
thanks for helping me.
 
Back
Top