Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- url := "https://www.lynda.com/allcourses/"
- output := A_ScriptDir . "\cources.txt"
- html := GetHtml(url) ; this may take time
- cources := GetCources(html)
- SaveToFile(output, cources)
- Run, % output
- GetHtml(url) {
- oWhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- oWhr.SetTimeouts(0, 120000, 120000, 120000)
- oWhr.Open("GET", url, true)
- oWhr.Send()
- oWhr.WaitForResponse()
- Return html := oWhr.ResponseText
- }
- GetCources(html) {
- doc := ComObjCreate("htmlfile")
- doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
- doc.write(html)
- 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].getAttribute("href")
- text .= (text ? "`r`n`r`n" : "") . "Title: " . itemText . "`r`nLink: " . itemLink
- }
- Return text
- }
- SaveToFile(filePath, string) {
- oFile := FileOpen(filePath, "w")
- oFile.Write(string)
- oFile.Close()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement