wouldjaball 5 Posted January 29, 2014 Report Share Posted January 29, 2014 Hi all,so I'm having trouble, and I think it's with loopingWhat I want to happen is to have the bot rotate thru the alphabet and scrape results BUT the bot needs to cycle thru the javascript code to go to the bottom of the page until the bottom of the page is reached for each letter. I want to add the data scraped from each letter to a total list.Here's what I have, I think I'm screwing up the looping somewhere... Thanks for any help! ui text box("Facebook Email", #FBemail)ui text box("Facebook Password", #FBpassword)ui text box("Last Name", #LastName)navigate("http://www.facebook.com", "Wait")type text($element offset(<email field>, 0), #FBemail, "Standard")clear list(%Alphabet)add list to list(%Alphabet, $list from file("C:\\Users\\Administrator\\Desktop\\Alphabet.txt"), "Delete", "Global")set(#Alphabetposition, $list item(%Alphabet, 0), "Global")type text($element offset(<password field>, 0), #FBpassword, "Standard")click(<login button>, "Left Click", "No")wait for browser event("Everything Loaded", "")navigate("www.facebook.com/friends/requests", "Wait")clear list(%TotalLastName)loop(1) { loop(1) { clear list(%LastNames) type text(<name="name_input">, "{#Alphabetposition} {#LastName}", "Standard") click(<id="u_0_x">, "Left Click", "No") wait for browser event("Everything Loaded", "") add list to list(%LastNames, $scrape attribute(<href=w"https://www.facebook.com/*?">, "href"), "Delete", "Global") set(#Loop, 0, "Global") loop while($comparison(#Loop, "!=", $list total(%LastNames))) { run javascript("window.scrollTo(0,document.body.scrollHeight)") wait(2) set(#Loop, $list total(%LastNames), "Global") wait for browser event("Everything Loaded", "") add list to list(%LastNames, $scrape attribute(<href=w"https://www.facebook.com/*?">, "href"), "Delete", "Global") if($comparison(#Loop, "=", %LastNames)) { then { increment(#Alphabetposition) } else { } } } add list to list(%TotalLastName, %LastNames, "Delete", "Global") }} Quote Link to post Share on other sites
UBotDev 276 Posted January 30, 2014 Report Share Posted January 30, 2014 Try with adding "wait for element" commands after every navigate/click/run javascript command. Quote Link to post Share on other sites
wouldjaball 5 Posted January 30, 2014 Author Report Share Posted January 30, 2014 thanks for the suggestion Ubotdev but that's not working... it's not looping all the way thru, and not scrolling. Quote Link to post Share on other sites
UBotDev 276 Posted January 30, 2014 Report Share Posted January 30, 2014 thanks for the suggestion Ubotdev but that's not working... it's not looping all the way thru, and not scrolling.Aa I said, you'll be safer by adding "wait for element" command, it might be the reason for some of your problems. I also noticed that you have an error on this line "if($comparison(#Loop, "=", %LastNames)) {" ....I think you are trying to compare #Loop to list size, that's why you should use $list total(%LastNames). Oh, and sometimes scrolling to the bottom only won't work, you'll also have to click "load more" button. Quote Link to post Share on other sites
wouldjaball 5 Posted January 30, 2014 Author Report Share Posted January 30, 2014 nice catch on the $list total, I will try ti implement later today! THanks! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.