Screen Scrape remove spaces/line breaks between specified tags

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 4
Reputation: webfort is an unknown quantity at this point 
Solved Threads: 0
webfort webfort is offline Offline
Newbie Poster

Screen Scrape remove spaces/line breaks between specified tags

 
0
  #1
Aug 23rd, 2008
Hi,

I'm doing a screen scrape of a web page, which works with out any problems

What I want to do is replace the contents of tag, I can do this if the tag match exactly but in this page there are allot of blank spaces.

lbltest.Text contains the page being scrapped. The tag is formatted like this

  1. <li class="thisclass">
  2.  
  3. TheText
  4.  
  5. </li>

I can't to a simple replace because of all the spaces. So I need to get it to look like this
  1. <li class="thisclass">TheText</li>

Any ideas how I might do this?

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Screen Scrape remove spaces/line breaks between specified tags

 
0
  #2
Aug 24th, 2008
Hi,
you specify, what method you are using to Scrape the Page . Have you heard Regex class?
KSG
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 4
Reputation: webfort is an unknown quantity at this point 
Solved Threads: 0
webfort webfort is offline Offline
Newbie Poster

Re: Screen Scrape remove spaces/line breaks between specified tags

 
0
  #3
Aug 24th, 2008
Hi,

This is the method I used:-
http://www.dotnetjohn.com/articles.aspx?articleid=93

Not heard of that class
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Screen Scrape remove spaces/line breaks between specified tags

 
0
  #4
Aug 24th, 2008
Regex is a Class that used for Regular Expressions. It is useful for Parsing.

For more detail, refer http://www.regular-expressions.info/dotnet.html
KSG
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 4
Reputation: webfort is an unknown quantity at this point 
Solved Threads: 0
webfort webfort is offline Offline
Newbie Poster

Re: Screen Scrape remove spaces/line breaks between specified tags

 
0
  #5
Aug 24th, 2008
Originally Posted by selvaganapathy View Post
Regex is a Class that used for Regular Expressions. It is useful for Parsing.

For more detail, refer http://www.regular-expressions.info/dotnet.html
thanks, how would I pick up on the line breaks and spaces, would it be possile to show me an example?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Screen Scrape remove spaces/line breaks between specified tags

 
0
  #6
Aug 26th, 2008
Ever heard of Trim(). Use it!
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 4
Reputation: webfort is an unknown quantity at this point 
Solved Threads: 0
webfort webfort is offline Offline
Newbie Poster

Re: Screen Scrape remove spaces/line breaks between specified tags

 
0
  #7
Aug 26th, 2008
Originally Posted by iamthwee View Post
Ever heard of Trim(). Use it!
I think you have missed the point, I need to replace line breaks and spaces, if you look at the example given, trim will not do this
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Screen Scrape remove spaces/line breaks between specified tags

 
0
  #8
Aug 26th, 2008
Incorrect, trim does replace line breaks and spaces. Please prove me wrong but you won't.

I have just tested it:

  1. Dim nl As String = System.Environment.NewLine
  2. Dim test As String = " " + nl + nl + " TheText " + nl + nl
  3.  
  4.  
  5. TextBox1.Text = test 'show original string in a multiline text box
  6. TextBox2.Text = test.Trim 'show changed string in a multiline text box
Last edited by iamthwee; Aug 26th, 2008 at 10:22 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Screen Scrape remove spaces/line breaks between specified tags

 
0
  #9
Aug 26th, 2008
Originally Posted by webfort View Post
thanks, how would I pick up on the line breaks and spaces, would it be possile to show me an example?
Hi,

Please google it for parsing HTML using Regex class. You will get a lot. Once you can able to parse HTML Tags, Ultimately you have to Use String.Trim() to remove unwanted white spaces .
KSG
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC