anonymous1184

Code Processing

Dec 21st, 2020 (edited)
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SetBatchLines, -1
  2.  
  3. min := 1 ; Course minimum
  4. , max := 999 ; Course maximun
  5. , limit := 5 ; Record limit (Cero means no limit)
  6. , codeList := A_Desktop "\list.txt" ; List of codes
  7. , results := A_Desktop "\results.csv" ; Results file
  8. , out := "Code,Course,Assign 1" "`n" ; Headings of the file
  9. , courses := ["PHE7", "PHE9", "PHE10", "PHE11", "PHE13"] ; Courses
  10. , URL := "https://gradecard.ignou.ac.in/gradecardB/Result.asp?eno=#&program=BSC&hidden_submit=OK"
  11.  
  12. loop, read, % codeList
  13. {
  14.  
  15.     if (limit && A_Index >= limit)
  16.     {
  17.         break
  18.     }
  19.  
  20.     html := getUrl(StrReplace(URL, "#", A_LoopReadline))
  21.  
  22.     for i,code in courses
  23.     {
  24.         if (RegExMatch(html, "(" code ").+>(\d+)<", match))
  25.         {
  26.             line := A_LoopReadline ","
  27.             if (match)
  28.             {
  29.                 if match2 between %min% and %max%
  30.                 {
  31.                     line .= match1 "," match2 "`n"
  32.                 }
  33.             }
  34.             out .= line
  35.         }
  36.     }
  37.  
  38. }
  39.  
  40. loop {
  41.     if (!fileObj := FileOpen(results, "w-"))
  42.     {
  43.         MsgBox, 0x40010, ERROR, Could not update the file, please close any open instance of the document and click OK
  44.     }
  45.     fileObj.Write(out)
  46.     if (!ErrorLevel)
  47.     {
  48.         MsgBox, 0x40040, Finished, Task Completed!
  49.     }
  50.     fileObj.Close()
  51. } until (!ErrorLevel)
  52.  
  53. getUrl(URL)
  54. {
  55.     whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
  56.     whr.Open("GET", URL, true)
  57.     whr.Send()
  58.     whr.WaitForResponse()
  59.     return whr.ResponseText
  60. }
  61.  
  62. #SingleInstance, force
  63.  
Add Comment
Please, Sign In to add comment