Jump to content

String Split Problem


Recommended Posts

I was trying to get source code of a site & split string using a keyword and what i want is text between two of those keyword . Example , site source has some code in which there are exactly two "<somekeyword>" , i want is text between these two , <somekeyword>sometext<somekeyword> , so i want here 'sometext' . Here's my code for it -

;Get Site Source Code
$URL="somesite.com/file.htmll"
$httpObj = ObjCreate("winhttp.winhttprequest.5.1")
$httpObj.open("GET",$URL)
$httpObj.send()
$HTMLSource = $httpObj.Responsetext
;Now split using keyword
$parsed=StringSplit ( $HTMLSource, "<somekeyword>" ,0 )
$script=$parsed[1] ; I think i should get required here but i get rubbish value like tml>
<9059<!DOCTYPE <!DOCTYPE  or something!

But it gives absturd value !

My version is v3 & source code can be as large as 50Kb. Please Help fast :|

Edited by Blankperson2
Link to comment
Share on other sites

  • Moderators

Hi, Blankperson2. How about providing us with the URL, or an example of the page source, so we can see what you're trying to accomplish? Otherwise we're just guessing :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@JLogano13 , never mind URL , i replaced that with a normal string instead like "<rubbish>fds<key>i want this text<key>lhglids" and split it via "<key>" and printed 2nd element but still gives rubbish value !

And when i replace "<key>" with a single character , bingo , it works !!!

Link to comment
Share on other sites

I haven't really checked your code deeply, but are you aware of what the parameter of '1' for the StringSplit command does?

That might be your problem, if your keyword is longer than a single character?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...