Hello, I'm trying to extract a certain string from a URL.

The URL is as follows: http://site.com/profiles/12345678

The Number is the value that I'm trying to retrieve, and write it to a text file. The way the data is displayed on the page, rather than the source is this:
<a href="http://site.com/profiles/1234567/">user</a>

I can open the source code and copy it, which will make it easier to retrieve the actual URL I want, but can anybody help me figure out how I would go about this? It's not for any botting, spamming, or other illegal purposes. I'd just like to collect a list of the user IDs without having to right click, copy address, then copy and paste the part I want. Thanks.

....

....

ListBox1.Items.Add(sections(sections.GetUpperBound(0) - 1))

doesnt work :(

hmmm... works great in vb 2008 express.... which version are you using (and what error does the IDE give you?)

hmmm... works great in vb 2008 express.... which version are you using (and what error does the IDE give you?)

I don't think i gave a good enough example of what the user names were supposed to look like, or the format anyways.

http://www.gaiaonline.com/forum/lifestyle-discussion/f.289/
<a href="/profiles/13374222/" title="View The Admin's profile">The Admin</a>
the bold part is that i need.

you don't need a login to access it.
If that gives you a better idea, then great.

I'm using VB 2008 Express.

Error

A first chance exception of type 'System.IndexOutOfRangeException' occurred in WindowsApplication1.exe

I'm sorry I did a terrible job of explaining.

The URL is actually like this:
<a href="/profiles/########">Their Username</a>

I need everything from the / after profiles to the " after the numbers.

Sorry about that. I've taken the source code of the link you posted, and tried it with that... made some modifications. Now it should work fine.

commented: Erebus, wtf is up with rick ashley arrrrgh!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -4

A simple Q&D solution

Dim MyUrl As String = "<a href=""/profiles/13374222/"" title=""View The Admin's profile"">The Admin</a>"
Dim StrArr() As String
Dim i As Integer
Dim UNum As Long

StrArr = Strings.Split(MyUrl, "/")

UNum = 0
For i = 0 To StrArr.GetUpperBound(0)
  If IsNumeric(StrArr(i)) Then
    UNum = CLng(StrArr(i))
    Exit For
  End If
Next i
MessageBox.Show("User: " & UNum.ToString, "User Number", MessageBoxButtons.OK, MessageBoxIcon.Information)

Not any full-blown URL parser.

commented: Clean and Concise... Nice Job :) +10

Really? Negative Rep For A Rick Roll? ;)

Like I wrote, a quick&dirty solution which may or may not work :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.