Example #1
0
def get_election_url_base(election_id, election_type):
    # TODO: get list of election_ids and input max(election_ids)
    election_type = static.get_election_type_id(election_type)
    if election_type in election_types.values():
        opts = {
            'electionId': '00%s' % election_id,
            'electionCode': election_type,
            'requestURI': '/electioninfo/00%s/pc/pcri03_ex.jsp' % election_id,
            'statementId': 'PCRI03_#%s' % election_type,
            }
        url = baseurl + urlencode(opts)
    else:
        raise Exception('Election types in [3,4,5,6,10,11]')
    return url
Example #2
0
def Crawler(nth, level):
    print level

    election_id = get_election_id(nth)
    valid_election_type_ids = get_valid_election_type_ids(election_id)
    if get_election_type_id(level) not in valid_election_type_ids:
        type_names = [reversed_election_types[t]\
                for t in valid_election_type_ids]
        raise Exception('Not valid election type for this election_id: %s'\
                % ','.join(type_names))

    if level in ['province_governor', 'education_governor']:
        crawler = CandCrawler(nth, level)
    else:
        crawler = OtherCandCrawler(nth, level)
    return crawler
Example #3
0
def Crawler(nth, level):
    print level

    election_id = get_election_id(nth)
    valid_election_type_ids = get_valid_election_type_ids(election_id)
    if get_election_type_id(level) not in valid_election_type_ids:
        type_names = [reversed_election_types[t]\
                for t in valid_election_type_ids]
        raise Exception('Not valid election type for this election_id: %s'\
                % ','.join(type_names))

    if level in ['province_governor', 'province_proportional']:
        crawler = ElectedCrawler(nth, level)
    else:
        crawler = OtherElectedCrawler(nth, level)
    return crawler
Example #4
0
 def url_list(self):
     url = self._url_list_base + self.format_suffix % self.args[self.nth]
     url += self.election_suffix % get_election_type_id(self.level)
     return url
Example #5
0
 def url_city_ids_json(self):
     return 'http://info.nec.go.kr/bizcommon/selectbox/selectbox_cityCodeBySgJson.json?electionId=0020140604&electionCode=%s' % get_election_type_id(self.level)
Example #6
0
 def url_list(self):
     url = self._url_list_base + self.format_suffix % self.args[self.nth]
     url += self.election_suffix % get_election_type_id(self.level)
     return url