Jump to content

String Manipulation


Recommended Posts

I'm trying to extract some data from a webpage...

I've been able to read the source of the webpage into a $String.

I'm looking for the command to use that will pick out a set of numbers following a particular code:

(In the source, wherever ".php=?guid" appears I want the following set of numbers to be put into an array)

The search pattern appears 250 times in the source with 250 number sets following.

Link to comment
Share on other sites

Search the helpfile for the String*() functions.

One that comes to mind is StringInStr()...

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I'm trying to extract some data from a webpage...

I've been able to read the source of the webpage into a $String.

I'm looking for the command to use that will pick out a set of numbers following a particular code:

(In the source, wherever ".php=?guid" appears I want the following set of numbers to be put into an array)

The search pattern appears 250 times in the source with 250 number sets following.

is there a consistent terminator to the numberstring (like a ? for the next variable) or a set length for the numberset? regexp is probably the most efficient way to go, but i hate regular expressions so if you can answer the questions above (and include a sample) i can write you a little parser.
Link to comment
Share on other sites

Thank You for helping -

I've used V2 for a long time now but I am a V3 noob.

I'm not concerned with or neatness or speed but anything that works is for me.

It would be a great to see each process step ; noted so I can follow steps and learn the coding but feel free to slap me down if that is too much to ask :lmao: .

The file attached is a portion of the source code $String I have read and I'm trying to extract two(2) items of data.

The first is always following the text: gallery.php?gid=

It is always six(6) digits.

After the six(6) digits there is always a: &

The second item is always in the next line of code following the discovery of the first item.

It always follows the text: <center>&nbsp; 

It can be a one(1), two(2), or three(3) digit number including zero(0).

After the digits there is always a: &

From the example attached I am looking to end up with two arrays including:

Array A= 170235,170233,170232,170231,170230

Array B= 190,0,8,91,7

SampleSource.txt

Link to comment
Share on other sites

Thank You for helping -

I've used V2 for a long time now but I am a V3 noob.

I'm not concerned with or neatness or speed but anything that works is for me.

It would be a great to see each process step ; noted so I can follow steps and learn the coding but feel free to slap me down if that is too much to ask :lmao: .

The file attached is a portion of the source code $String I have read and I'm trying to extract two(2) items of data.

The first is always following the text: gallery.php?gid=

It is always six(6) digits.

After the six(6) digits there is always a: &

The second item is always in the next line of code following the discovery of the first item.

It always follows the text: <center>  

It can be a one(1), two(2), or three(3) digit number including zero(0).

After the digits there is always a: &

From the example attached I am looking to end up with two arrays including:

Array A= 170235,170233,170232,170231,170230

Array B= 190,0,8,91,7

From your example,

This might give you an idea of one way to play with strings.

Find.au3

Link to comment
Share on other sites

regexp all the way :lmao:

you should really learn it cameronsdad.

$s_Source = FileRead('index.php')

$ai_Array_A = StringRegExp($s_Source, '<center>&nbsp;((?:\d)*?)&nbsp;</td>.*?<center>&nbsp;(?:\d)*?&nbsp;</td>', 3)
$ai_Array_B = StringRegExp($s_Source, '<center>&nbsp;(?:\d)*?&nbsp;</td>.*?<center>&nbsp;((?:\d)*?)&nbsp;</td>', 3)

for $i = 0 to UBound($ai_Array_A)-1
    ConsoleWrite($ai_Array_A[$i] & @LF & $ai_Array_B[$i] & @CRLF)
Next

btw who the fuck wrote that site. it has like 200 center tags that are never closed.

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

regexp all the way :lmao:

you should really learn it cameronsdad.

$s_Source = FileRead('index.php')

$ai_Array_A = StringRegExp($s_Source, '<center>&nbsp;((?:\d)*?)&nbsp;</td>.*?<center>&nbsp;(?:\d)*?&nbsp;</td>', 3)
$ai_Array_B = StringRegExp($s_Source, '<center>&nbsp;(?:\d)*?&nbsp;</td>.*?<center>&nbsp;((?:\d)*?)&nbsp;</td>', 3)

for $i = 0 to UBound($ai_Array_A)-1
    ConsoleWrite($ai_Array_A[$i] & @LF & $ai_Array_B[$i] & @CRLF)
Next

btw who the fuck wrote that site. it has like 200 center tags that are never closed.

bah, regular expressions are why i never really got into perl. I would typically just rather have a few extra lines of code that i can read, then spend the time to learn regexp. but i'll tell you what; because you're one of the people that i seriously respect on here, i'll take your advice and check out regexp today. i can't guarantee that i'll ever use them in the future, but i WILL check them out today.
Link to comment
Share on other sites

haha thanks o:)

IMO once you know it it will be easyer to read then tons of String* lines :lmao:

I havent ever gotten into Regular Expressions, just because usually I dont have the time to figure out something new, but it definitely is on my list of things to learn. I saw an excellent book on it once, I plan on purchasing. Unfortunately I dont remember the title :king: or anything about it really. ;)

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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...