0

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.

3
Contributors
8
Replies
9
Views
8 Years
Discussion Span
Last Post by Teme64
0

....

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

doesnt work :(

0

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

0

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.

-1

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.

Votes + Comments
Erebus, wtf is up with rick ashley arrrrgh!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1

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.

Votes + Comments
Clean and Concise... Nice Job :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.