We help IT Professionals succeed at work.
Get Started

vb.net - gather text from web page

304 Views
Last Modified: 2015-03-04
First of all I should point out I am looking to gather some text from our own companys internal website and no try to do anything naughty to external websites.

I have an Windows Forms Application that performs many useful functions that our Desktop Analysts use on a regular basis, one of these is to show who is logged on to a PC and what their full name is.

I want to go a little further...

It can already open our internal directory website and search for the name of the person logged on to provide a photo, telephone number, position, area they work in, etc. But this is an extra click. I want my app to gather this info such as telephone number, area they work in and maybe even import the photo.

So this is how it works so far:

Dim ADUsername As String = txtUsername.Text
            Dim newusername As String = ADUsername.Split("\"c)(1)
            Dim cluesLookup As String = "https://intranet/directory/servlet/domain.intranet.server.servlet.CorpDir?SearchType=Everyone&NumSearchFields=1&DisplayStart=1&SortColumn=null&Ascending=&Advanced=null&SearchField0=LAN+User+ID&SearchOperator0=Contains&ShowAllResults=true&NumOfResultsToDisplay=15&SearchText0=" & newusername
            Process.Start(cluesLookup)

Open in new window


Which brings up the results of the search which includes the name and a telephone number. This on its own would be acceptable as I can at least gather the telephone number from this source code:
<td align="left" valign="top" CLASS="oddrow">+44 1234 567890</td>
This is the portion of the source code I am interested in:
<td align="left" valign="top" CLASS="oddrow"><a href="/intranet/servlet/domain.intranet.server.servlet.ShowPersonalInfo?SearchType=Everyone&SearchDN=recid=PPS-000A4801,OU=People,dc=domain,dc=com" onMouseOver="self.status='View personal information'; return true" onMouseOut="self.status=''">Firstname Surname</a>

Open in new window


What I would need from this code is recid=PPS-000A4801 because I could then use it to bring up the full details of the person using this link:
https://intranet.domain.com/intranet/servlet/intranet.domain.server.servlet.ShowPersonalInfo?SearchType=Everyone&SearchDN=recid=PPS-000A4801,OU=People,dc=domain,dc=com

This page shows all the info I am looking for, in particular these sections of the source code:
<td><b> Internal Email Address</b></td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<td colspan="3"><a href="mailto:surname_firstname@domain.com">surname_firstname@domain.com</a></td>

<td><IMG src="https://pictures.domain.com/private/pictures/4658572099.jpg" border=0> </td>

Open in new window


There's some other stuff I can pick out once I get a good idea of how to do it.
What I would like to do is for the end user to click a button which would silently gather the RECID=PPS-xxxxxxxx number, constructs the link which contains the full information and then gathers the required text from the webpage to populate in my Windows Forms Application.

There is no API I can use to get this info unfortunately and this internal website is the only repository for this info. There is no RECID in AD for example that I could use.

So...any thoughts?
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 16 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE