dbb1480 Posted April 12, 2019 Share Posted April 12, 2019 Hi All, Moderate user here. I am trying to click a button on a webpage and can't seem to be able to do it. This is the html code <a class="auth-required btn blue" data-ajax="data-ajax" data-ajax-href="/user/5a3496eba0da4d0051258446/follow_user" data-ajax-method="post" data-pa-name="follow_user" id="follow-user">Follow</a> All I want to do is hit the button but so far everything I have tried through object grabbing hasn't worked. I'm sure the solution is extremely simple and I am mising something. Any help is much appreciated. Thank You! Link to comment Share on other sites More sharing options...
Danp2 Posted April 12, 2019 Share Posted April 12, 2019 Help us help you by providing sufficient details, such as -- Which browser? Which website? What have you tried thus far (show your code)? Etc Also, please explain why you need to automate clicking on a Follow button. yutijang 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dbb1480 Posted April 12, 2019 Author Share Posted April 12, 2019 Sorry I typed that really quick earlier today It is in IE I have tried this thinking the href of the link would work but so far nothing Local $oIE = _IEAttach("website") Local $oLinks = _IELinkGetCollection($oIE) Local $iNumLinks = @extended Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks $sTxt &= $oLink.href & @CRLF Next Local $aArray = StringSplit($sTxt, @CR) _ArrayDisplay($aArray,") I'd rather not say the name of the site but it is a marketplace website where you follow people to see what they are selling, the more you follow the more you items you can see for sale Link to comment Share on other sites More sharing options...
jdelaney Posted April 13, 2019 Share Posted April 13, 2019 (edited) So,what's the output of the array? also. Rather than concatenating strings and then string splitting, you can just _arrayadd. or in the loop, consolewrite. Edited April 13, 2019 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
dbb1480 Posted April 13, 2019 Author Share Posted April 13, 2019 im actually getting no output from the array since the array is not returning data-ajax-href="/user/5a3496eba0da4d0051258446/follow_user" that i was looking for above Link to comment Share on other sites More sharing options...
alienclone Posted April 13, 2019 Share Posted April 13, 2019 https://www.autoitscript.com/autoit3/docs/libfunctions/_IELinkClickByText.htm If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
dbb1480 Posted April 13, 2019 Author Share Posted April 13, 2019 Hi alienclone I did try click link by text a few times as well. No luck so far. From the above HTML code I was assuming the links name is follow_user Link to comment Share on other sites More sharing options...
Danp2 Posted April 13, 2019 Share Posted April 13, 2019 For us to help, you'll need to provide more details than "doesn't work". Show your code. Show the results from the Scite output panel. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dbb1480 Posted April 13, 2019 Author Share Posted April 13, 2019 I'm very sorry, I have been trying to do this all day with a fussy 6 month old on my lap..... Here is more complete html code <div class="d-fl jc-sb"><div class="user-content"><a href="/closet/paintedhanger"><img alt="paintedhanger" class="user-image l" src="https://di2ponv0v5otw.cloudfront.net/users/2019/04/03/5ca2ae5b86a604d9a65a45dd/t_5ca54ecab50281c375851c75.jpg" title="paintedhanger"></a><label><h4><a href="/closet/paintedhanger">!</a></h4><h5><a href="/closet/paintedhanger">@paintedhanger</a></h5></label></div><div class="d-fl ai-c"><a class="auth-required btn blue" data-ajax="data-ajax" data-ajax-href="/user/5ca2ae5b86a604d9a65a45dd/follow_user" data-ajax-method="post" data-pa-name="follow_user" id="follow-user">Follow</a><a class="auth-required btn t-btn f-hide" data-ajax="data-ajax" data-ajax-href="/user/5ca2ae5b86a604d9a65a45dd/unfollow_user" data-ajax-method="post" data-pa-name="unfollow_user" id="unfollow-user">Following</a></div></div> I am trying to select the user and follow that user by hitting the follower_user link. In this case the user is paintedhanger. I have a very basic understanding of html code so I have tried things like Local $oIE = _IEAttach("website") _IELinkClickByText($oIE, "/user/5ca2ae5b86a604d9a65a45dd/follow_user") or Local $oIE = _IEAttach("website") _IELinkClickByText($oIE, "follow_user") or #include <Array.au3> #include <Date.au3> #include <IE.au3> #include <File.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> local $userId = "5ca2ae5b86a604d9a65a45dd" Local $oIE = _IEAttach("website") ;attachs current IE webpage to program Local $oTitle = _IEPropertyGet ($oIE, "title" ) ;gets webpage title Local $oForm = _IEGetObjByID($oIE, $userid) ;grabs information of specific listing based on listing ID $colTags = _IETagNameGetCollection($oForm, "a") For $oTag In $colTags If $oTag.className = "follow" Then ;searches for share link $oFound = $oTag ExitLoop EndIf Next _IEAction($oFound,"click") ;clicks the follow button the console either gives me a $_IESTATUS_NoMatch, or --> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (5ca54ecab50281c375851c75) --> IE.au3 T3.0-2 Error from function _IETagNameGetCollection, $_IESTATUS_InvalidDataType "test.au3" (19) : ==> Variable must be of type "Object".: For $oTag In $colTags I'm sorry I didn't provide more coding examples sooner. I tried a bunch of misc other small things, but nothing seems to work, I am sure the answer is pretty simple and something dumb I am overlooking. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 13, 2019 Developers Share Posted April 13, 2019 @dbb1480, It took me a whole 2 minutes to find the website and their TERMS which between the shitload of verbiage also states: Quote In connection with your use of the Service you shall not engage in or use any data mining, robots, scraping or similar data gathering or extraction methods. Wouldn't you say you are in violation with that with this script? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Danp2 Posted April 13, 2019 Share Posted April 13, 2019 (edited) This works for me -- -snip- (Sorry, but i guess we crossed posting and I like to get an answer first on my post.. Jos) Edited April 13, 2019 by Jos Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dbb1480 Posted April 13, 2019 Author Share Posted April 13, 2019 you are right jos i have found the terms too i will delete script, thank you for your help Link to comment Share on other sites More sharing options...
Recommended Posts