control find a text on a webpage and then click and download the files to a specific location

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
abhay_547
Posts: 12
Joined: 16 Apr 2016, 12:12

control find a text on a webpage and then click and download the files to a specific location

11 Feb 2018, 23:58

Hi, I am very new to AHK and still exploring. I have a intranet webpage (my firm's internal network portal designed with apache aurora, it doesn't seem to be normal html) where i have multiple download links with the text "Download" hyperlinked. I want to find that text and loop through page and then click on each one of it and then save the files on a specific shared drive location. is this possible to achieve it through ahk. can someone help. i got this below so far (through google search) and this works with only internet explorer whereelse i need to access my intranet portal on chrome since it doesn't work properly with internet explorer for some reason.

Code: Select all

webpagename:= "http://internalportal/"
searchterm:= "download"

for wb in ComObjCreate("Shell.Application").Windows

	If InStr(wb.locationURL, webpagename)
	{
		Links := wb.Document.Links
		Loop % Links.Length
	If InStr(Links[A_Index-1].InnerText, searchterm)
		Links[A_Index-1].Click()
 	}
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: control find a text on a webpage and then click and download the files to a specific location

16 Feb 2018, 01:27

I am not sure we can help a lot with this code, since it is, afaik, COM-related code which cannot work with Chrome in any way.

Also, the information that you deal with something that isn't "normal html" is not really helpful. How does the source code look? What means "doesn't work properly", anyway? What happens when you run the code above?
All in all, there isn't much to work within your post. Perhaps, you could try Imagesearch instead, with a picture of the "Download" link and then click at the coordinates - but if there are many links and you have to scroll, it might be difficult to keep an overview.

On the other hand, there is this almost brandnew library by Geekdude which lets you automate Chrome, but I have no idea how it will perform with "not-normal html", especially because it seems to still rely to some extent on Internet Explorer and COM "under the hood": https://autohotkey.com/boards/viewtopic.php?t=42890

Btw, did you already talk to the guys who provide this page with the download links and ask if they could provide a better way of downloading? Perhaps they can also shed some light how to use IE with this intranet webpage.
abhay_547
Posts: 12
Joined: 16 Apr 2016, 12:12

Re: control find a text on a webpage and then click and download the files to a specific location

18 Feb 2018, 12:00

on the webpage the links are not on a image, it's hyperlinked text "Download" and when I click on it, it gives me a popup to save that file on my drive which is either a xlsx, csv or pdf file. I want the AHK script to search for the text "Download" on the webpage first and then click on that and then save the download file on a specified share drive path.
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: control find a text on a webpage and then click and download the files to a specific location

18 Feb 2018, 14:27

Imagesearch doesn't mean that the links have to be images, but that you would "take" an image of how they look and then let the script look for these (if the links all "look" the same).
That's probably not the best or most reliable method, but with the given information I cannot recommend much more. That's why I asked, how the source code of this "not-normal" html looks like, what it means that Internet Explorer is "not working properly" and if the people who set up the webpage could shed some light...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 208 guests