StealthBot.net: How do I split up lines when parsing websites? - StealthBot.net

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How do I split up lines when parsing websites? Split two lines in a web's source code and join them into one

#1 User is offline   WataBoy7 Icon

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 36
  • Joined: April-25 12

Posted May 20, 2012 - 12:49 AM

I need to know how to join two lines after parsing a website. Well, more specifically, let's say I've isolated a sentence, except that it runs two lines long when you view the website's source code. Let's assume that you don't know beforehand what words the sentence contains (meaning its contents are, as far as you're concerned, random), and I have no way of knowing at what point the first line breaks and the next begins. How would I go about joining two separate lines in a string into one line, such that the single-line string can be displayed properly in chat?

For instance, let's say the two lines in the website's code are as follows:

Hello, baker, I would like
to buy a blueberry muffin.


I want to join it into a whole and complete line:
Hello, baker, I would like to buy a blueberry muffin.


Also, here's a relatively unrelated tidbit: when I output to just my Stealthbot window, the original 'unedited' lines display fine. Yet when I switch the output over to chat, it doesn't show at all :(

Using the constant vbNewLine I've tried this:
line = Replace(line, vbNewLine, vbNullString)

Yet it's not doing anything. Can I get some help?

This post has been edited by WataBoy7: May 20, 2012 - 12:56 AM


#2 User is offline   RosieSuckedMe Icon

  • Full Member
  • PipPipPip
  • Group: Members
  • Posts: 251
  • Joined: March-17 11

Posted May 20, 2012 - 09:13 AM

newLine = firstLine & secondLine

??

This post has been edited by RosieSuckedMe: May 20, 2012 - 09:13 AM


#3 User is offline   PhiX Icon

  • Notice the ownage.
  • PipPipPipPipPipPipPipPipPip
  • Group: Guests
  • Posts: 8,388,607
  • Joined: July-31 09

Posted May 20, 2012 - 09:50 AM

View PostWataBoy7, on May 20, 2012 - 02:49 AM, said:

Using the constant vbNewLine I've tried this:
line = Replace(line, vbNewLine, vbNullString)
This would be the correct way of accomplishing what you want. Did you try it with Chr(10) or Chr(13) instead of vbNewLine already?

Note: You might have to replace vbNullString with a space.
PhiX

BNLS: phix.no-ip.org

Please refrain from sending me personal messages regarding technical support issues. Use the forums, that is what they are there for.

#4 User is offline   WataBoy7 Icon

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 36
  • Joined: April-25 12

Posted May 20, 2012 - 05:54 PM

View PostPhiX, on May 20, 2012 - 04:50 AM, said:

This would be the correct way of accomplishing what you want. Did you try it with Chr(10) or Chr(13) instead of vbNewLine already?

Note: You might have to replace vbNullString with a space.

Chr(10) worked perfectly. Thanks! The constant is vbLf, though for some reason vbNewLine (which should include this) did not work :o

One last question, is there a method to reload/refresh a website, in case its contents have been updated recently?

This post has been edited by WataBoy7: May 20, 2012 - 05:56 PM


#5 User is offline   Fallen-God Icon

  • Full Member
  • PipPipPip
  • Group: Members
  • Posts: 364
  • Joined: September-11 09

Posted May 22, 2012 - 10:44 PM

View PostWataBoy7, on May 20, 2012 - 06:54 PM, said:

Chr(10) worked perfectly. Thanks! The constant is vbLf, though for some reason vbNewLine (which should include this) did not work :o

One last question, is there a method to reload/refresh a website, in case its contents have been updated recently?

Presumably just re-do the request you did to get the page source in the first place?
Choose Functional.

#6 User is offline   WataBoy7 Icon

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 36
  • Joined: April-25 12

Posted May 30, 2012 - 06:38 PM

View PostFallen-God, on May 22, 2012 - 05:44 PM, said:

Presumably just re-do the request you did to get the page source in the first place?


I tried that, but it didn't work. My function uses the retrieval of a site's source code with the normal method:
webObj = CreateObject("Microsoft.XMLHTTP")
webObj.Open "GET", <URL name>, False
webObj.Send
web = webObj.responseText


I even tried declaring webObj and web as function-specific variables, but it doesn't RE-GET the website, for some reason. The source code is the same even though when you would normally refresh the site you would get something different. I was wondering if there was a method like this:
webObj.Refresh
webObj.Reload

This post has been edited by WataBoy7: May 30, 2012 - 06:39 PM


#7 User is offline   Novynn Icon

  • Silver Member
  • PipPipPipPipPip
  • Group: Members
  • Posts: 873
  • Joined: October-07 09

Posted May 30, 2012 - 07:06 PM

View PostWataBoy7, on May 31, 2012 - 07:38 AM, said:

' Initializes the random seed
Randomize
...
webObj = CreateObject("Microsoft.XMLHTTP")
' All results are cached so you have to add something random the URL each time
webObj.Open "GET", <URL name> & "&x=" & Rnd, False
webObj.Send
web = webObj.responseText


#8 User is offline   WataBoy7 Icon

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 36
  • Joined: April-25 12

Posted June 01, 2012 - 12:00 AM

Thank you! I figured something along those lines anyway :lol:

This post has been edited by WataBoy7: June 01, 2012 - 12:00 AM


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users