Skip to content

Instantly share code, notes, and snippets.

@shriphani
Created May 1, 2013 20:55
Show Gist options
  • Save shriphani/5498312 to your computer and use it in GitHub Desktop.
Save shriphani/5498312 to your computer and use it in GitHub Desktop.
Grabs and prints a list of top-level forums on Gaia online
'''
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