Jump to content

Review my function (issues with array)


Recommended Posts

Summary of what I am trying to do with this function:

Basically the script is checking to see if a url stored in $URL is the same as the website title. The reason I want to do this is because I want to scan a list of urls and check which pages have parked domains. Usually the parked domain will show up with the url in the title. The URLs are stored like this: http://www.google.com

$url2 removes the first 11 letters off the url so it looks like this: google.com

$url3 removes the first 7 letters off the url so it looks like this: www.google.com

$array1 gets the webpage title and stores it like this (using google.com as example) 0 | Google

Where I am having issues:

Basically the bold statement below is where I am having the issues. I want to check to see if the webpage has google.com or www.google.com in the page title (google.com is just used as example). So I am trying to compare $url2 and $url3 against $array1. Then if they don't match then it writes the url to a log file. I am having issues with the comparing the array and the variables. Everything else in the script works as intended. Any ideas on what I am doing wrong? Have search all over google and I am getting nothing so I guess i'll go to the experts! I think its something about doing a comparison of a string and an array.

func check2()

$url2 = StringTrimLeft(""&$URL, 11)

$url3 = StringTrimLeft(""&$URL, 7)

$array1 = _StringBetween(_INetGetSource (""&$URL), "<title>", "</title>")

_ArrayDisplay($array1)

If $url2 = $array1 Then

MsgBox(4096,"", "URL is same as title")

Elseif $url3 = $array1 Then

MsgBox(4096,"", "URL is same as title")

Else

FileWriteLine( "C:\Documents and Settings\admin\My Documents\logfile2.txt", $URL)

EndIf

endfunc

Thanks for any feedback!

Edited by james3452453245
Link to comment
Share on other sites

$url2 = $array1
You can't compare a variable that contains a String against a variable that contains a Array that way. Your need to loop through the Array Elements and compare your string against them(Array element, or cell -> Array[Element])

- Array use: http://www.autoitscript.com/autoit3/docs/intro/lang_variables.htm

- For..Next: http://www.autoitscript.com/autoit3/docs/intro/lang_loops.htm (there are 2 flavors here)

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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