Created
September 25, 2013 10:04
-
-
Save syusui-s/6697599 to your computer and use it in GitHub Desktop.
某大学のWebサイトから自分の時間割をスクレイピングするJavaScriptコード。時間割表示して、ブラウザのコンソールに打ち込むと、文字列が返ってきてくれるはず。ChromeとFirefoxで動作確認済み。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var schedule = new Array(); | |
| rows=document.getElementsByClassName("schedule_box")[0].rows; | |
| for(var i=1;i<rows.length;i+=2){ | |
| cells=rows[i].cells; | |
| var days=new Array(); | |
| for(var j=1;j<cells.length;j++){ | |
| days.push(cells[j].textContent.replace(/\s/g, '')); | |
| } | |
| schedule.push(days); | |
| } | |
| for(var i=0;i<schedule.length;i++){ | |
| var days = schedule[i]; | |
| for(var j=0;j<days.length;j++){ | |
| days[j]='"'+days[j].toString()+'"' | |
| } | |
| schedule[i] = '['+days.toString()+']' | |
| } | |
| '['+schedule.toString()+']' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment