VadVergasov / CodeforcesApiPy

Implementation of https://codeforces.com API
GNU General Public License v3.0
28 stars 4 forks source link

Add support for additional APIs #5

Closed nileshsah closed 3 years ago

nileshsah commented 3 years ago

To support the use-cases in the project https://github.com/nileshsah/harwest-tool, it'll be great to have additional APIs to support:

(1) Getting a count of the total number of submission-page for a user Could be achieved by scraping the count from the user submissions page, example

   def get_submissions_page_count(self):
        base_url = "https://codeforces.com/submissions/" + self.user
        sub_soup = self.__get_content_soup(base_url)
        pages = sub_soup.findAll('span', attrs={'class': 'page-index'})
        return int(pages[-1].find('a').text)

(2) Getting the tags for a given problem Id Even though it's possible to get the tags for a problem via the Codeforces API, it lacks the tag for the rating of the problem which would be quite crucial to have, and hence scraping might be the only viable option. Example,

    def get_contest_tags(self, problem_url):
        con_soup = self.__get_content_soup(problem_url)
        span_tags = con_soup.findAll('span', attrs={'class': 'tag-box'})
        return [x.text.strip() for x in span_tags]
VadVergasov commented 3 years ago

(1) I think, that getting the total page count is a bad idea - we can just get all problems. (2) I'll do it in the nearest future.

nileshsah commented 3 years ago

Sorry for the confusion, (1) is not required indeed.