Skip to content

Instantly share code, notes, and snippets.

@BadUncleX
Last active April 11, 2018 05:45
Show Gist options
  • Save BadUncleX/f9f93e6cbbc96f77cca7 to your computer and use it in GitHub Desktop.
Save BadUncleX/f9f93e6cbbc96f77cca7 to your computer and use it in GitHub Desktop.
machine learning index | 机器学习资料索引
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "Missing parentheses in call to 'print' (<ipython-input-1-d24bfa26baf0>, line 6)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-1-d24bfa26baf0>\"\u001b[0;36m, line \u001b[0;32m6\u001b[0m\n\u001b[0;31m print \"Downloaded Subtitle No. \",\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m Missing parentheses in call to 'print'\n"
]
}
],
"source": [
"import urllib2\n",
"import os\n",
"url = 'https://class.coursera.org/ml-005/lecture/subtitles?q='\n",
"#url2 = '_en&format=srt'\n",
"url2 = '_en&format=txt'\n",
"print \"Downloaded Subtitle No. \", \n",
"for i in range(1,115):\n",
" try:\n",
" remoteurl = urllib2.urlopen(url+str(i)+url2)\n",
" cd = remoteurl.info()['Content-Disposition'].split(';')\n",
" cd2 = cd[1].split('=')[1].strip(\"\\\"'\")\n",
" filename = urllib2.unquote(cd2).replace(\"/\",\"_\")\n",
" print \"filename:\", filename\n",
"\n",
"\n",
" page = remoteurl.read();\n",
"\n",
" f = open('subtitle/'+filename,'w+');\n",
" f.write(page);\n",
" f.close();\n",
" print i,;\n",
" except (urllib2.HTTPError, urllib2.URLError) as e:\n",
" print '\\nProblem Downloading file: ',i\n",
" print 'OR Connection Error'\n",
"\n",
"print '\\nDownload Finished\\nHappy Coding!!!'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"colors": {
"hover_highlight": "#DAA520",
"navigate_num": "#000000",
"navigate_text": "#333333",
"running_highlight": "#FF0000",
"selected_highlight": "#FFD700",
"sidebar_border": "#EEEEEE",
"wrapper_background": "#FFFFFF"
},
"moveMenuLeft": true,
"nav_menu": {
"height": "12px",
"width": "252px"
},
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 4,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false,
"widenNotebook": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment