Jump to content
Sign in to follow this  
null

HTML parser, variables, loops, etc

Recommended Posts

This is my first post so I apologize if I posted in the wrong section. I think this is the right place no?

I host music on a youtube channel and every day I seek out youtube listeners in the same genre of music and either subscribe to their channel or invite them to become friends. I have a good background in perl/php/asp/bash/batch but new to AutoIt. I think once I get over the language barrier I will be able to create code that will basically think and work as I am doing (manually) right now. Problem is getting started. I got the concept right but I am getting very confused with the syntax and that is where I need some help/clarification.

Here is what I am trying to do (in sudo) ...

- open a URL to a youtube account but to their page that displays their subscribers

-- example: such as http://www.youtube.com/profile?user=XYZ_USER&view=subscribers

- grab all HTML with <body> tags

- parse out youtube user accounts based on sytax found in HTML source

-- example: assign (to variable) value "ABC_USER" from HTML line appearing as ...

---- "<a href="/user/ABC_USER" onmousedown="yt.analytics.trackEvent('ChannelPage', 'subscriptions_text_link', 'XYZ_USER - ABC_USER')" title="ABC_USER" rel="followed-by">ABC_USER</a>

* there will be multiple occurrences of this pattern.

For each occurrence,

- begin loop

- open in new IE or new tab

-- do stuff (I think I will be able to code this stuff and is too much to include in this post for help)

-- close window/tab

-- end loop

with the above information, where I am stuck is at the step of handling an array. In perl or php, I would run through a loop adding each value as a new entry into an existing array. I am starting to think AutoIt handles this differently. From multiple searches on example scripts it looks like I just run something to the effect of this ...

#include <ie.au3>

#Include <String.au3>

$oIE = _IECreate("http://www.youtube.com/profile?user=XYZ_USER&view=subscribers")

$sString = _IEBodyReadHTML($oIE) ; grab all HTML body content and add to #sString array

$TUBEUSERS = _StringBetween($sString, '<a href="/user/', '" onmousedown') ; $TUBEUSERS is an array now consisting of just usernames

; code for either a "for" or "while" loop goes here

$USERoIE = _IECreate("http://www.youtube.com/user/$TUBEUSER")

; do stuff

; end loop

Im sorry for the messy explanation ...

So basically I need to figure out more on the concept of how AutoIt sorts through HTML body tags and if it will assign and populate $sString as an array element or if it will treat it as a variable (thus overwriting the previous value with a new value. Also, what is the easiest and simplest way to run through an array for the number of values in an array? Something like for each $value in @array, do stuff.

Edited by null

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...