Created
May 1, 2013 20:55
-
-
Save shriphani/5498312 to your computer and use it in GitHub Desktop.
Grabs and prints a list of top-level forums on Gaia online
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
| ''' | |
| Grab a list of Gaia Online forums | |
| ''' | |
| import os | |
| import re | |
| import requests | |
| from BeautifulSoup import BeautifulSoup, SoupStrainer | |
| GAIA_ONLINE_MAIN_INDEX = 'http://www.gaiaonline.com/forum/' | |
| GAILA_ONLINE_HOST = 'http://www.gaiaonline.com/' | |
| def main(): | |
| '''download forums list from gaia online''' | |
| resp = requests.get(GAIA_ONLINE_MAIN_INDEX) | |
| soup = BeautifulSoup(resp.text) | |
| for item in soup.findAll('li', attrs = {'class' : re.compile(r'^f.*c.*')}): | |
| for link in item.findAll('a'): | |
| if link.has_key('href'): | |
| print os.path.join(GAILA_ONLINE_HOST, link['href'][1:]) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment