Lynda.com workaround

Get help with using AutoHotkey and its commands and hotkeys
teadrinker
Posts: 590
Joined: 29 Mar 2015, 09:41
Contact:

Re: Lynda.com workaround

21 Feb 2019, 02:08

My last try. :)
(Temporarily can't post here because of problems with the forum firewall)
For me this code in Windows 7 produces ERROR_WINHTTP_SECURE_CHANNEL_ERROR, but maybe will work for you.
Portwolf
Posts: 115
Joined: 08 Oct 2018, 12:57

Re: Lynda.com workaround

21 Feb 2019, 02:42

Hello again :)

Well, it's a bust. And i cannot figure out why.
Browsers work perfectly on that machine. Address is the same.. But always fail the script.

First error:
Image

Second error:
Image

:facepalm:


Runing latest version of AHK, updated Windows, no idea on what is going on.
(and yeah, the firewall on the forum is really, REALLY annoying..) :think:
teadrinker
Posts: 590
Joined: 29 Mar 2015, 09:41
Contact:

Re: Lynda.com workaround

21 Feb 2019, 02:50

Does UrlDownloadToFile load html on that machine?
teadrinker
Posts: 590
Joined: 29 Mar 2015, 09:41
Contact:

Re: Lynda.com workaround

21 Feb 2019, 11:18

Portwolf wrote: Browsers work perfectly on that machine.
In that case this should work:

Code: Select all

url := "https://www.lynda.com/allcourses/"
output := A_ScriptDir . "\cources.txt"

if !doc := GetDocument(url, ie, timeout := 120000)
   ExitApp
cources := GetCources(doc)
ie.Quit()
SaveToFile(output, cources)
Run, % output

GetDocument(url, ByRef ie, timeout) {
   try ie := ComObjCreate("InternetExplorer.Application")
   catch e {
      MsgBox, % "Can't create InternetExplorer.Application.`n" . e.Message
      Return
   }
   OnExit( Func("Exit").Bind(ie) )
   ie.Visible := false
   ie.Navigate(url)
   if WaitForLoad(ie, timeout)
      Return ie.document
   else {
      ie.Quit()
      MsgBox, timed out!
   }
}

GetCources(doc) {
   courceContainer := doc.querySelector("ul.course-list")
   items := courceContainer.getElementsByTagName("h3")
   Loop % items.length {
      item := items[A_Index - 1]
      itemText := item.innerText
      itemLink := item.getElementsByTagName("a")[0].href
      text .= (text ? "`r`n`r`n" : "") . "Title: " . Trim(itemText) . "`r`nLink:  " . Trim(itemLink)
   }
   Return text
}

WaitForLoad(ie, time := 0xFFFFFFFF)  {
   start := A_TickCount
   Loop
      Sleep, 200
   until (ie.ReadyState = 4 && !ie.Busy && ie.document.readyState = "Complete") || (A_TickCount - start > time && notLoad := 1)
   Return !notLoad
}

SaveToFile(filePath, string) {
   oFile := FileOpen(filePath, "w")
   oFile.Write(string)
   oFile.Close()
}

Exit(ie)  {
   try ie.Quit()
}
User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Lynda.com workaround

21 Feb 2019, 11:57

- This worked for me on Windows 7.

Code: Select all

q:: ;url download html to string
vUrl := "https://www.lynda.com/allcourses/"
try
{
	oHTTP := ComObjCreate("MSXML2.XMLHTTP.6.0")
	oHTTP.Open("GET", vUrl)
	oHTTP.Send()
	vText := oHTTP.ResponseText
	oHTTP := ""
}
catch
{
	oHTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	oHTTP.Open("GET", vUrl)
	oHTTP.Send()
	vText := oHTTP.ResponseText
	oHTTP := ""
}
Clipboard := vText
MsgBox, % vText
return
- @teadrinker: Thanks for the code.
- ERROR_WINHTTP_SECURE_CHANNEL_ERROR sounds like this:
WinHttpRequest (An error occurred in the secure channel support) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=58051

Code: Select all

ERROR_WINHTTP_SECURE_CHANNEL_ERROR := 0x2F7D ;source: winhttp.h
WININET_E_SECURITY_CHANNEL_ERROR := 0x80072F7D ;source: winerror.h
- Do you have any good sources on SetRequestHeader?
E.g. What are the advantages of doing these:

Code: Select all

oHTTP.SetRequestHeader("Pragma", "no-cache")
oHTTP.SetRequestHeader("Cache-Control", "no-cache, no-store")
- I did find this. Thanks.
HTTP/1.1: Header Field Definitions
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Last edited by jeeswg on 21 Feb 2019, 12:25, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
teadrinker
Posts: 590
Joined: 29 Mar 2015, 09:41
Contact:

Re: Lynda.com workaround

21 Feb 2019, 12:17

jeeswg wrote:
21 Feb 2019, 11:57
- ERROR_WINHTTP_SECURE_CHANNEL_ERROR sounds like this:
WinHttpRequest (An error occurred in the secure channel support) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=58051
jeeswg, thanks! I already googled about this problem, found the tip to install the upadate kb3140245, it turned that update is already present in my Windows 7.
Portwolf
Posts: 115
Joined: 08 Oct 2018, 12:57

Re: Lynda.com workaround

21 Feb 2019, 19:55

teadrinker wrote:
21 Feb 2019, 02:50
Does UrlDownloadToFile load html on that machine?
I'll haver to check it out in the weekend at work, as im off tomorrow... Working weekend this week :P
I'll also check out the solutions presented from both you and Jeeswg.

Thank you boys, you're golden, both of you!

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, Bing [Bot], eqv, esp901, JoeWinograd and 55 guests