Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Recent Matches for the day #28

Open
Ehsan1997 opened this issue Aug 15, 2018 · 3 comments
Open

Get Recent Matches for the day #28

Ehsan1997 opened this issue Aug 15, 2018 · 3 comments

Comments

@Ehsan1997
Copy link
Contributor

Ehsan1997 commented Aug 15, 2018

Currently we get matches from the entire week. I would like to get them by days too. I wrote a script for that which I am using currently I will share it here.

Also summary.py has some problem when trying to create a Summary object.


Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\ehsan\AppData\Local\Programs\Python\Python36\lib\site-packages\espncricinfo\summary.py", line 7, in __init__
    self.json = self.get_json()
  File "C:\Users\ehsan\AppData\Local\Programs\Python\Python36\lib\site-packages\espncricinfo\summary.py", line 13, in get_json
    return r.json()
  File "C:\Users\ehsan\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\models.py", line 896, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\ehsan\AppData\Local\Programs\Python\Python36\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\ehsan\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\ehsan\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)

Code for getting matches by the day.

    def get_recent_matches_day(date=None):
        if date:
            #date format should be YYYYmmdd e.g. 20180814
            url = "http://www.espncricinfo.com/scores/?date=date"
        else:
            url = "http://www.espncricinfo.com/scores/"
        r = requests.get(url)
        soup = BeautifulSoup(r.text, 'html.parser')
        return [x['href'].split('/', 4)[4].split('.')[0] for x in soup.findAll('a', href=True, text='SCORECARD')]
@dwillis
Copy link
Collaborator

dwillis commented Aug 18, 2018

@Ehsan1997 thanks - it looks like the Summary object json url no longer works.

@scrambldchannel
Copy link
Contributor

Yeah, I get a 404 for the summary.json url. There is an RSS feed of current matches (http://static.cricinfo.com/rss/livescores.xml) that could be used to get current matches. I might try to knock something together to parse this if anyone's interested.

@dwillis
Copy link
Collaborator

dwillis commented Nov 9, 2019

@scrambldchannel That would be awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants