[{"data":1,"prerenderedAt":199},["ShallowReactive",2],{"i-lucide:menu":3,"i-lucide:arrow-up-right":8,"i-lucide:moon":10,"i-lucide:sun":12,"i-lucide:rss":14,"i-simple-icons:github":16,"i-simple-icons:linkedin":18,"post-\u002F2012\u002Fscraping-for-grades":21,"surround-\u002F2012\u002Fscraping-for-grades":186,"i-lucide:arrow-left":195,"i-lucide:arrow-right":197},{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":7},0,24,false,"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 5h16M4 12h16M4 19h16\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":9},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M7 7h10v10M7 17L17 7\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":11},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":13},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Ccircle cx=\"12\" cy=\"12\" r=\"4\"\u002F>\u003Cpath d=\"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":15},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M4 11a9 9 0 0 1 9 9M4 4a16 16 0 0 1 16 16\"\u002F>\u003Ccircle cx=\"5\" cy=\"19\" r=\"1\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":17},"\u003Cpath fill=\"currentColor\" d=\"M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":19,"hidden":20},"\u003Cpath fill=\"currentColor\" d=\"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037c-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85c3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.06 2.06 0 0 1-2.063-2.065a2.064 2.064 0 1 1 2.063 2.065m1.782 13.019H3.555V9h3.564zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0z\"\u002F>",true,{"id":22,"title":23,"body":24,"category":168,"comments":169,"date":170,"description":171,"excerpt":169,"extension":172,"image":169,"meta":173,"navigation":20,"path":174,"readingTime":175,"seo":176,"stem":177,"subtitle":169,"tags":178,"wordCount":184,"__hash__":185},"posts\u002F2012\u002Fscraping-for-grades.md","Scraping for grades",{"type":25,"value":26,"toc":166},"minimark",[27,40,144,162],[28,29,30,31,35,39],"p",{},"The student information system (ÕIS) our college is using satisfies most (if not all) the requirements presented to it. Still, I found a fault: there's no API and I wanted to get notified ASAP when a new grade is added.\nSome background: I recently started a wonderful online learning course: SAAS-class.org (",[32,33],"a",{"href":34},"https:\u002F\u002Fwww.coursera.org\u002Fsaas\u002Fclass",[32,36,34],{"href":34,"rel":37},[38],"nofollow",") where I got the opportunity & incentive to dive into Ruby (on Rails).\nSo, my first ever Ruby class was born. The code uses Mechanize to log into the grade system, navigates to the correct page and scrapes the grades into an Hash structure. The end user can basically just do this:",[41,42,47],"pre",{"className":43,"code":44,"language":45,"meta":46,"style":46},"language-ruby shiki shiki-themes github-light github-dark","require \"itk_grades\"\n# Create instance and save login data\nITK = ITKGrades.new(\"user\", \"pass\")\n# Fetch &amp; scrape grades from ÕIS.\nITK.fetch\n#ITK.grades # Returns a hash of all grades\n# Print all grades\nITK.print\n","ruby","",[48,49,50,63,70,105,111,122,128,134],"code",{"__ignoreMap":46},[51,52,55,59],"span",{"class":53,"line":54},"line",1,[51,56,58],{"class":57},"szBVR","require",[51,60,62],{"class":61},"sZZnC"," \"itk_grades\"\n",[51,64,66],{"class":53,"line":65},2,[51,67,69],{"class":68},"sJ8bj","# Create instance and save login data\n",[51,71,73,77,80,83,87,90,93,96,99,102],{"class":53,"line":72},3,[51,74,76],{"class":75},"sj4cs","ITK",[51,78,79],{"class":57}," =",[51,81,82],{"class":75}," ITKGrades",[51,84,86],{"class":85},"sVt8B",".",[51,88,89],{"class":57},"new",[51,91,92],{"class":85},"(",[51,94,95],{"class":61},"\"user\"",[51,97,98],{"class":85},", ",[51,100,101],{"class":61},"\"pass\"",[51,103,104],{"class":85},")\n",[51,106,108],{"class":53,"line":107},4,[51,109,110],{"class":68},"# Fetch &amp; scrape grades from ÕIS.\n",[51,112,114,116,118],{"class":53,"line":113},5,[51,115,76],{"class":75},[51,117,86],{"class":85},[51,119,121],{"class":120},"sScJk","fetch\n",[51,123,125],{"class":53,"line":124},6,[51,126,127],{"class":68},"#ITK.grades # Returns a hash of all grades\n",[51,129,131],{"class":53,"line":130},7,[51,132,133],{"class":68},"# Print all grades\n",[51,135,137,139,141],{"class":53,"line":136},8,[51,138,76],{"class":75},[51,140,86],{"class":85},[51,142,143],{"class":75},"print\n",[28,145,146,147,151,152,156,157],{},"You can see the full code over @ ",[32,148,150],{"href":149},"https:\u002F\u002Fgist.github.com\u002F1944799","GitHub"," or the college ",[32,153,155],{"href":154},"https:\u002F\u002Fwiki.itcollege.ee\u002Findex.php\u002FITKGrades.rb","Wiki"," (in Estonian).\n",[158,159],"img",{"alt":160,"src":161},"Screenshot","\u002Fcontent\u002F2012\u002F03\u002Fterminal.png",[163,164,165],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":46,"searchDepth":65,"depth":65,"links":167},[],"Projects",null,"2012-03-02","The student information system (ÕIS) our college is using satisfies most (if not all) the requirements presented to it. Still, I found a fault: there's no API and I wanted to get notified ASAP when a new grade is added.\nSome background: I recently started a wonderful online learning course: SAAS-class.org (https:\u002F\u002Fwww.coursera.org\u002Fsaas\u002Fclass) where I got the opportunity & incentive to dive into Ruby (on Rails).\nSo, my first ever Ruby class was born. The code uses Mechanize to log into the grade system, navigates to the correct page and scrapes the grades into an Hash structure. The end user can basically just do this:","md",{},"\u002F2012\u002Fscraping-for-grades","less than 1 minute",{"title":23,"description":171},"2012\u002Fscraping-for-grades",[179,180,181,182,183],"html","Ruby","school","mechanizer","scripting",159,"Xhe41Y-6WSsRwiU7BrK5-TCsc1ls0JQMBWHZSKfghcs",[187,191],{"title":188,"path":189,"stem":190,"children":-1},"Infosüsteemide eetikaprobleemid","\u002F2012\u002Finfosusteemide-eetikaprobleemid","2012\u002Finfosusteemide-eetikaprobleemid",{"title":192,"path":193,"stem":194,"children":-1},"Lessons learned","\u002F2012\u002Flessons-learned","2012\u002Flessons-learned",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":196},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m12 19l-7-7l7-7m7 7H5\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":198},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 12h14m-7-7l7 7l-7 7\"\u002F>",1790228554973]