auto search driver site

Get help with using AutoHotkey and its commands and hotkeys
famko
Posts: 15
Joined: 30 May 2019, 02:18

auto search driver site

Post by famko » 23 Jan 2021, 03:49

Hi guys, i am trying to get a script go to https://drp.su/en/catalog-soft fill in a text field and hit the search button and download the listed driver.
But i can't get it to work. I found an example but it uses getElementsByid. But this not present on this site. I have tried getElementByclassName and getElementByTagName, but i can't get it to work.

for some reason i can't put in de url in the topic, it's reported as a broken link.

hope someone can help me..
thans in advance
Famko

site elements

Code: Select all

<form class="pure-form SoftSearchForm__group-medium SoftSearchForm__group" action="/search-soft" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11"><input name="query" class="SoftSearchForm__input" type="text" placeholder="Software or&nbsp;category name" value="" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=10" autocomplete="off"><span class="SoftSearchForm__btn-holder" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=11"><button class="SoftSearchForm__btn" type="submit" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=11.0"><span class="icon-search SoftSearchForm__icon" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=11.0.$=10"></span><span class="SoftSearchForm__btn-text" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=11.0.$=11">Find</span></button></span></form>


<span class="SoftSearchForm__btn-holder" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=11"><button class="SoftSearchForm__btn" type="submit" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=11.0"><span class="icon-search SoftSearchForm__icon" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=11.0.$=10"></span><span class="SoftSearchForm__btn-text" data-reactid=".f4xndwkga0.0.1.0.$=12.$=10.$=11.0.$=11.$=10.$=11.$=11.0.$=11">Find</span></button></span>

Code: Select all

seachdriver := "PCI\VEN_8086&DEV_1E3A&SUBSYS_08061025&REV_04"

URL :="https://drp.su/en/catalog-soft"

WB := ComObjCreate("InternetExplorer.Application")
WB.Visible := True
WB.Navigate(URL)
While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
Sleep, 10
wb.document.getElementByTagName("query").value := seachdriver
;wb.document.getElementByclassName("query").value := seachdriver
;wb.document.getElementsByTagName("SearchForm__btn")[1].Click()
While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
Sleep, 10

ExitApp
return
Last edited by BoBo on 23 Jan 2021, 07:58, edited 1 time in total.
User avatar
boiler
Posts: 6870
Joined: 21 Dec 2014, 02:44

Re: auto search driver site

Post by boiler » 23 Jan 2021, 09:32

They are not getElementByClassName and getElementByTagName. They are getElementsByClassName and getElementsByTagName, each will return an array, the first element being (for example) getElementsByTagName("query")[0]. (however query doesn’t look to be a tag name in your html)
famko
Posts: 15
Joined: 30 May 2019, 02:18

Re: auto search driver site

Post by famko » 23 Jan 2021, 10:56

Thanks Boiler

got it working, not sure if there is a better way.
The only thing i need is to get the url from button "download zip"
Any Idea?

Code: Select all

searchdriver := "PCI\VEN_8086&DEV_1E3A&SUBSYS_08061025&REV_04 "


URL :="https drp.su /en/catalog"  Broken Link for safety

WB := ComObjCreate("InternetExplorer.Application")
WB.Visible := True
WB.Navigate(URL)
WinMove, ahk_class IEFrame,, 200,100,800,600
While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
Sleep, 500
wb.document.getElementsByName("query")[0].value := searchdriver
sleep 1000

MouseClick, left, 630, 365
sleep 500
Send, {space}
sleep 500
wb.document.getElementsByClassName("SearchForm__btn")[0].Click()

malcev
Posts: 865
Joined: 12 Aug 2014, 12:37

Re: auto search driver site

Post by malcev » 24 Jan 2021, 04:53

As I see drp.su has api.
You can send http requests with winhttprequest directly to it EndPoints.
Like this https://drp.su/api/search
famko
Posts: 15
Joined: 30 May 2019, 02:18

Re: auto search driver site

Post by famko » 24 Jan 2021, 07:58

I have emailed them. Have to wait for answer. But is it possible without api, or am I trying something that will not succeed ? 
thans so far
malcev
Posts: 865
Joined: 12 Aug 2014, 12:37

Re: auto search driver site

Post by malcev » 24 Jan 2021, 08:14

I think this API is private.
You have to examine what You send and receive from server.
It can be done, for example in Developer tools in browser.
And then send the same data with ahk winhttprequest.
famko
Posts: 15
Joined: 30 May 2019, 02:18

Re: auto search driver site

Post by famko » 24 Jan 2021, 08:21

Never done that.
Is this what you are referring to?

Code: Select all

<script id="spHTMLFormElementPrototypeScript">(function()
  {
    try
    {
      var sp_old_HTMLFormElementPrototype_submit = HTMLFormElement.prototype.submit;
      HTMLFormElement.prototype.submit = function(AEvent)
      {
        try
        {
          var spEvent = document.createEvent('Event');
          spEvent.initEvent('sp_submit', true, true);
          this.dispatchEvent(spEvent);
        }
        catch(ErrorMessage)
        {
          console.error('spFormElementPrototype() Error sending "sp_submit" event from HTMLFormElement.prototype.submit: ' + ErrorMessage);
        }
        sp_old_HTMLFormElementPrototype_submit.apply(this);
      };
    }
    catch(ErrorMessage)
    {
      console.error('spFormElementPrototype() Error attaching to HTMLFormElement.prototype.submit: ' + ErrorMessage);
    }

    try
    {
      if (typeof __doPostBack == 'function')
      {
        var sp_old__doPostBack = __doPostBack;
        __doPostBack = function(eventTarget, eventArgument)
        {
          try
          {
            var spEvent = document.createEvent('Event');
            spEvent.initEvent('sp_submit', true, true);
            window.dispatchEvent(spEvent);
          }
          catch(ErrorMessage)
          {
            console.error('spFormElementPrototype() Error sending "sp_submit" event from __doPostBack(): ' + ErrorMessage);
          }
          sp_old__doPostBack(eventTarget, eventArgument);
        };      
      }
    }
    catch(ErrorMessage)
    {
      console.error('spFormElementPrototype() Error attaching to __doPostBack(): ' + ErrorMessage);
    }
  })();</script>
malcev
Posts: 865
Joined: 12 Aug 2014, 12:37

Re: auto search driver site

Post by malcev » 24 Jan 2021, 08:23

No.

Code: Select all

HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", "https://www.autohotkey.com", true)
HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko")
HTTP.SetRequestHeader("Pragma", "no-cache")
HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store")
HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
HTTP.Send()
HTTP.WaitForResponse()
msgbox % HTTP.ResponseText
Post Reply

Return to “Ask For Help”