Created
November 14, 2014 16:40
-
-
Save fourohfour/6938e4ad3f59c18dda26 to your computer and use it in GitHub Desktop.
French Words
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
import urllib.request | |
for i in range(10): | |
while True: | |
req = urllib.request.Request("http://fr.wiktionary.org/wiki/Sp%C3%A9cial:Page_au_hasard") | |
page = urllib.request.urlopen(req) | |
page = str(page.read()) | |
psplit = page.split('<h1 id="firstHeading" class="firstHeading" lang="fr">', 1) | |
title = psplit[1].split("</h1>", 1)[0] | |
newtitle = "" | |
add = True | |
for char in title: | |
if char == "<": | |
add = False | |
if add: | |
newtitle = newtitle + char | |
if char == ">": | |
add = True | |
if "\\" in newtitle: | |
continue | |
else: | |
break | |
print(newtitle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment