PDA

View Full Version : Web Browser Automation: favorite all items on page, move to next page



joshehren
05-01-2015, 09:10 AM
Hello. I'm new to VBA, and I'm flailing in my efforts, so I'm grateful for any help you could offer me. My wife participates on a number of Etsy teams whose purpose is to 'favorite' the items of other team members. All she has to do is visit the forum and favorite all of the items posted. This involves simply clicking on all the heart symbols on the page, and then moving onto the next page, and so on. (see the attached jpg for a screen shot of one page).

How can I write some VBA that would click on all the heart icons in the forum? It's not permitted for her to go in and click all of the items in one sitting however. She has to do it throughout the day. Is there a way to write code that would cover x pages, then separate code to address y pages (staring where x left off), then separate code that would address whatever remains?

Here is the source code for the 'favorite' icon.

<div class="button-fave-container">
<input type="hidden" class="favorite-url" value="/add_favorite_listing.php">
<input type="hidden" class="unfavorite-url" value="/remove_favorite_listing.php">
<input type="hidden" class="id" name="listing_id" value="200313226">
<input type="hidden" class="type" value="listing">


<input type="hidden" class="favorited-text" value="Favorite">
<input type="hidden" class="unfavorited-text" value="Favorite">
<input type="hidden" class="favoriting-text" value="Favorite">
<input type="hidden" class="unfavoriting-text" value="Favorite">


<input type="hidden" name="_nnc" value="3:1430493077:zmkIv76PdFfwErCegyF_f-JeKZtO:3b7b14567a742a2b0ac70fc85e6efa7de36d3eae939a76efe7ce94b44883f721" class="hidden csrf">

<a class="button-fave favorited-button" rel="200313226" alt="Added to favorites">
<span class="status-text">Favorite</span><div class="button-spinner"></div>



Here is what I've got thus far:
Function FillInternetForm()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")


IE.Navigate "notallowedtopostlinks"


IE.Visible = True
While IE.busy
DoEvents
Wend

IE.Document.All("username").Value = ThisWorkbook.Sheets("sheet1").Range("a1")
IE.Document.All("password").Value = ThisWorkbook.Sheets("sheet1").Range("a2")
IE.Document.All("signin_button").Click

IE.Navigate "notallowedtopostlinks/"

Thanks again for your help.
josh

joshehren
05-01-2015, 11:53 AM
Here is the URL: etsy.com/teams/24446/the-promo-mall/discuss/16290092/page/1

joshehren
05-06-2015, 09:34 AM
Nothing? Is there something I need to clarify in order to get help? I have been working with Selenium to see if I can understand the html behind the Favorite button, but I'm not making much progress.

Does anyone have any recommendations for some tutorials that address what I need to do?

Thanks again,
josh