benners Posted June 20, 2017 Share Posted June 20, 2017 I am wondering if there is a quicker and more robust way to achieve what the script below does. What I am trying to do is open a web page, click a link then do some stuff with the linked page. This is a minimal producer from a bigger script, no error checking etc, that opens the web page, searches the page for a link (it's an onclick link and despite my best try couldn't get it to click) based on a string, then combines two strings to get the link and navigates to it. The issue is the main part of the final url is hard coded in the script and could change in the future. Any better solutions? Thanks #include <IE.au3> _Web_GetUpdateInfoFromMUC('Update for Microsoft Office 2010 (KB3114555) 64-Bit Edition') Func _Web_GetUpdateInfoFromMUC($s_Title) Local $o_IE = _IECreate('https://catalog.update.microsoft.com/v7/site/Search.aspx?q=' & $s_Title) $v_Ret = _Web_MucGetUpdateDetailsUrl($o_IE, $s_Title) If $v_Ret Then _IENavigate($o_IE, $v_Ret) MsgBox(0, 'Wait', 'This is the url I want') _IEQuit($o_IE) EndFunc ;==>_Web_GetUpdateInfoFromMUC Func _Web_MucGetUpdateDetailsUrl(ByRef $o_Browser, $s_Title) Local $s_Url = '' Local $o_Links = _IELinkGetCollection($o_Browser) If Not @error Then For $o_Link In $o_Links If StringInStr(_IEPropertyGet($o_Link, "innerText"), $s_Title) Then $s_Url = StringReplace($o_Link.id, '_link', '') ExitLoop EndIf Next EndIf ; below is the hard coded part that MS may change Return 'https://catalog.update.microsoft.com/v7/site/ScopedViewInline.aspx?updateid=' & $s_Url EndFunc ;==>_Web_MucGetUpdateDetailsUrl Link to comment Share on other sites More sharing options...
Danp2 Posted June 21, 2017 Share Posted June 21, 2017 You can click the link with this -- _IEAction($o_Link, 'click') However, it opened in a popup window when I did this. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
benners Posted June 21, 2017 Author Share Posted June 21, 2017 (edited) I had tried this, but got a message about having a pop up blocker active (which I do) but this doesn't happen when I click the link manually so thought I was doing something wrong. The normal action is to open a pop up window, but I got around that with IENavigate. I had also tried IELinkClickByText and Index cheers Edited June 21, 2017 by benners Link to comment Share on other sites More sharing options...
Danp2 Posted June 21, 2017 Share Posted June 21, 2017 Yes, I had to specifically tell IE that it was ok to allow popups for this site. Then the _IEAction worked as expected. I only pointed out the ability to click the link because you stated earlier that you were unable to accomplish this. Have you considered using _INetGetSource and then parse the resulting text to retrieve the desired data? Perhaps one of the Regex gurus around here could assist with this. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
benners Posted June 21, 2017 Author Share Posted June 21, 2017 (edited) I hadn't any success when I posted but even though I should have just walked away after posting I had to persist I hadn't thought about _INetGetSource, I will look into it and see if I can make it quicker. Thanks Edited June 21, 2017 by benners typo Link to comment Share on other sites More sharing options...
Bert Posted February 10, 2020 Share Posted February 10, 2020 Have you looked at trying to do this with command line? I googled a bit and it looks possible. It would make things much more stable and no screen scraping needed. Google "office update check command line" The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now