Guest User

Untitled

a guest
Feb 21st, 2019
130
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. url := "https://www.lynda.com/allcourses/"
  2. output := A_ScriptDir . "\cources.txt"
  3.  
  4. html := GetHtml(url) ; this may take time
  5. cources := GetCources(html)
  6. SaveToFile(output, cources)
  7. Run, % output
  8.  
  9. GetHtml(url) {
  10.    oWhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
  11.    oWhr.SetTimeouts(0, 120000, 120000, 120000)
  12.    oWhr.Open("GET", url, true)
  13.    oWhr.Send()
  14.    oWhr.WaitForResponse()
  15.    Return html := oWhr.ResponseText
  16. }
  17.  
  18. GetCources(html) {
  19.    doc := ComObjCreate("htmlfile")
  20.    doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
  21.    doc.write(html)
  22.    courceContainer := doc.querySelector("ul.course-list")
  23.    items := courceContainer.getElementsByTagName("h3")
  24.    Loop % items.length {
  25.       item := items[A_Index - 1]
  26.       itemText := item.innerText
  27.       itemLink := item.getElementsByTagName("a")[0].getAttribute("href")
  28.       text .= (text ? "`r`n`r`n" : "") . "Title: " . itemText . "`r`nLink:  " . itemLink
  29.    }
  30.    Return text
  31. }
  32.  
  33. SaveToFile(filePath, string) {
  34.    oFile := FileOpen(filePath, "w")
  35.    oFile.Write(string)
  36.    oFile.Close()
  37. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×