Giter VIP home page Giter VIP logo

baronet2 / firstcyclingapi Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 2.0 6.02 MB

An unofficial Python API wrapper for firstcycling.com

Home Page: https://firstcyclingapi.readthedocs.io/en/latest/

License: MIT License

Python 100.00%
api cycling cyclinganalytics python scraper scraping scraping-python scraping-websites sports sports-analytics sports-data sports-science sports-stats sportsanalytics tourdefrance

firstcyclingapi's People

Contributors

baronet2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

firstcyclingapi's Issues

RaceEditionResults endpoint broken

Hi, thx for the library, it is really helping. In race/race.py there is

self._get_endpoint(endpoint=RaceEditionResults, l=classification_num, e=zero_padded_stage_num)

And in constants.py I see
classifications = {'general': 1, 'youth': 2, 'points': 3, 'mountain': 4, 'sprint': 6}

So I suppose that l=1 should give me the general. However, it does not. FirstCycling seems not to work anymore like that. Can you confirm the current state?

Seems to no longer work

When I run py.test in the root directory I get the following result.

Python version is 3.9.7

================================================= test session starts ==================================================
platform darwin -- Python 3.9.7, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/admin/Documents/GitHub/FirstCyclingAPI
plugins: anyio-2.2.0
collected 0 items / 3 errors

======================================================== ERRORS ========================================================
_________________________________________ ERROR collecting tests/test_race.py __________________________________________
ImportError while importing test module '/Users/admin/Documents/GitHub/FirstCyclingAPI/tests/test_race.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../opt/anaconda3/lib/python3.9/importlib/init.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_race.py:1: in
from first_cycling_api import Race, RaceEdition
first_cycling_api/init.py:8: in
from .rider import Rider
first_cycling_api/rider/init.py:23: in
from .rider import Rider
first_cycling_api/rider/rider.py:3: in
from ..api import fc
first_cycling_api/api.py:8: in
from slumber import API
E ModuleNotFoundError: No module named 'slumber'
________________________________________ ERROR collecting tests/test_ranking.py ________________________________________
ImportError while importing test module '/Users/admin/Documents/GitHub/FirstCyclingAPI/tests/test_ranking.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../opt/anaconda3/lib/python3.9/importlib/init.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_ranking.py:1: in
from first_cycling_api import Ranking
first_cycling_api/init.py:8: in
from .rider import Rider
first_cycling_api/rider/init.py:23: in
from .rider import Rider
first_cycling_api/rider/rider.py:3: in
from ..api import fc
first_cycling_api/api.py:8: in
from slumber import API
E ModuleNotFoundError: No module named 'slumber'
_________________________________________ ERROR collecting tests/test_rider.py _________________________________________
ImportError while importing test module '/Users/admin/Documents/GitHub/FirstCyclingAPI/tests/test_rider.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../opt/anaconda3/lib/python3.9/importlib/init.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_rider.py:1: in
from first_cycling_api import Rider
first_cycling_api/init.py:8: in
from .rider import Rider
first_cycling_api/rider/init.py:23: in
from .rider import Rider
first_cycling_api/rider/rider.py:3: in
from ..api import fc
first_cycling_api/api.py:8: in
from slumber import API
E ModuleNotFoundError: No module named 'slumber'
=============================================== short test summary info ================================================
ERROR tests/test_race.py
ERROR tests/test_ranking.py
ERROR tests/test_rider.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================== 3 errors in 15.89s ==================================================

Installing the Library

Hey there, just wondering if this library is available on PyPi? I don't see anything in the docs about how to install this library.

Parse details in rider sidebar

As identified in #17 , due to a recent change to the website layout, the old code to parse the sidebar information on rider pages no longer works. It would be nice to bring back this functionality.

KeyError: "None of ['Information'] are in the columns"

Discussed in #17

Originally posted by bfransol June 4, 2022
Hello,
I'm currently trying to use this repository for my studies, however I get the following error whent trying to retreive data from Rider.

code:

from first_cycling_api import Rider
roglic = Rider(16672)
print(roglic.best_results())

error:

Traceback (most recent call last):
  File "C:/Users/2de Master/Predictive and Prescriptive Analytics/FirstCyclingAPI-main/ExtractData.py", line 10, in <module>
    print(roglic.best_results())
  File "C:\Users\2de Master\Predictive and Prescriptive Analytics\FirstCyclingAPI-main\first_cycling_api\rider\rider.py", line 43, in best_results
    return self._get_endpoint(high=1)
  File "C:\Users\2de Master\Predictive and Prescriptive Analytics\FirstCyclingAPI-main\first_cycling_api\objects.py", line 25, in _get_endpoint
    return endpoint(response)
  File "C:\Users\2de Master\Predictive and Prescriptive Analytics\FirstCyclingAPI-main\first_cycling_api\endpoints.py", line 39, in __init__
    self._parse_result()
  File "C:\Users\2de Master\Predictive and Prescriptive Analytics\FirstCyclingAPI-main\first_cycling_api\endpoints.py", line 43, in _parse_result
    self._parse_soup()
  File "C:\Users\2de Master\Predictive and Prescriptive Analytics\FirstCyclingAPI-main\first_cycling_api\rider\endpoints.py", line 25, in _parse_soup
    self._get_sidebar_details()
  File "C:\Users\2de Master\Predictive and Prescriptive Analytics\FirstCyclingAPI-main\first_cycling_api\rider\endpoints.py", line 44, in _get_sidebar_details
    details = pd.Series(details_df.set_index('Information')['Information.1'])
  File "C:\Users\anaconda3\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\anaconda3\lib\site-packages\pandas\core\frame.py", line 5451, in set_index
    raise KeyError(f"None of {missing} are in the columns")
KeyError: "None of ['Information'] are in the columns"

I was wondering if someone could help me out with it.
Thanks in advance!

Convert endpoints to properties

Returning Endpoint instances rather than storing these as properties introduces unnecessary complexity to the Rider and Race sections. It would be better to return the relevant result directly, or return the raw response if it is not being parsed.

For example,Race(XX).victory_table().table should become Race(XX).victory_table.

Such calls should automatically update properties common to all endpoints of that instance, such as Race(XX).header_details. To avoid losing data, all raw responses should be accessible somehow.

Where we accept parameters for the methods, we can separate these into separate attributes or use dictionary syntax instead. For example, Rider(XX).year_results(2020).results_df should become Rider(XX).year_results[2020].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.