Jump to content

Searching for a string


Recommended Posts

Hello guys,

So I was trying to pull out the information from a web page. I manage to get the whole information on text, what I want to do is to find a string then once the program finds the string, it'll then print out the first 5 letters after that string. Any ideas with this? This is my code so far, I was able to put out the string to check, what I want to do is print out the first five letters after that. Thanks in advance.

$webBrowser = _IECreate("http://google.com", 0, 0, 1)
Local $sText = _IEBodyReadText($webBrowser)
$iPosition = StringInStr("" & $sText & "", "Google.com.ph")
$sString = StringMid("" & $sText & "", $iPosition, 13)
MsgBox(0, "Test", $sString)

 

Link to comment
Share on other sites

Try:

$webBrowser = _IECreate("http://google.com", 0, 0, 1)
$sText = _IEBodyReadText($webBrowser)
$sSearchfor = "google.com.ph" ; Edit this
$iLength = StringLen($sSearchfor) ; Don't edit this

$iPosition = StringInStr($sText, $sSearchfor)
$sString = StringMid("" & $sText & "", $iPosition + $ilength, 5)
MsgBox(0, "Test", $sString)

 

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

22 minutes ago, rcmaehl said:

Try:

$webBrowser = _IECreate("http://google.com", 0, 0, 1)
$sText = _IEBodyReadText($webBrowser)
$sSearchfor = "google.com.ph" ; Edit this
$iLength = StringLen($sSearchfor) ; Don't edit this

$iPosition = StringInStr($sText, $sSearchfor)
$sString = StringMid("" & $sText & "", $iPosition + $ilength, 5)
MsgBox(0, "Test", $sString)

 

That's it. Thanks, bro. :)

Edited by jmstubiera
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

×
×
  • Create New...