Created
October 25, 2018 12:16
-
-
Save vool/baff6365ce81a9be71a2291bacd1184f to your computer and use it in GitHub Desktop.
The lowest whole number without a wikipedia (en) entry
This file contains 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import urllib.request, urllib.error\n", | |
"from itertools import count" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"baseurl = \"https://en.wikipedia.org/wiki/\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"404 - https://en.wikipedia.org/wiki/2553\n" | |
] | |
} | |
], | |
"source": [ | |
"for i in count(0):\n", | |
" req = urllib.request.Request(baseurl+str(i))\n", | |
" try:\n", | |
" urllib.request.urlopen(req)\n", | |
" except urllib.error.HTTPError as e:\n", | |
" print(str(e.code)+\" - \"+baseurl+str(i) )\n", | |
" break" | |
] | |
} | |
], | |
"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.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment