#!/usr/bin/python import ox.web.imdb import re import json import sys from optparse import OptionParser ''' python allofcountry.py in idsofindia.json python allofcountry.py tr idsofturkey.json ''' def reset_url(url): x = ox.web.imdb.read_url(url, timeout=0) if __name__ == '__main__': usage = "usage: %prog [options] country output.json" parser = OptionParser(usage=usage) parser.add_option('-r', '--reset', dest='reset', default=None, help="reset given url") (opts, args) = parser.parse_args() if len(args) != 2: parser.print_help() sys.exit(1) films = [] country, output = args base_url = 'http://akas.imdb.com' url = '%s/search/title?countries=%s&sort=year' % (base_url, country) data = ox.web.imdb.read_url(url) n = True while n: n = re.compile('Next »').findall(data) if n: n = '%s%s' % (base_url, n[0].split('href="')[-1]) results = re.compile('