trainline-python icon indicating copy to clipboard operation
trainline-python copied to clipboard

All requests give 400 error

Open baptistesola2 opened this issue 4 years ago • 4 comments

trainline version: 0.1.0 Python version: 3.7 Operating System: macOS

Description All requests return the same error: requests.exceptions.ConnectionError: Status code 400 for url https://www.trainline.eu/api/v5_1/search {"error":{"code":"no_results","message":{}}}

Basically the same issue as last time

baptistesola2 avatar Jan 12 '21 17:01 baptistesola2

Hey, now I have a 403 requests.exceptions.ConnectionError: Status code 403 for url https://www.trainline.eu/api/v5_1/search Someone has a fix ? Or I will try to dig into it to fix it

yann120 avatar Jul 11 '22 10:07 yann120

I also found a 403. It seems that the API has like a captcha? Is that possible?

python3 trainline_cli.py --departure="Toulouse" --arrival="Bordeaux" --next=12hours
Traceback (most recent call last):
  File "/Users/PERE/Developer/trainline-python/trainline_cli.py", line 104, in <module>
    main()
  File "/Users/PERE/Developer/trainline-python/venv-trainline/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/PERE/Developer/trainline-python/venv-trainline/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/PERE/Developer/trainline-python/venv-trainline/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/PERE/Developer/trainline-python/venv-trainline/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/PERE/Developer/trainline-python/trainline_cli.py", line 70, in main
    results = trainline.search(
  File "/Users/PERE/Developer/trainline-python/trainline/__init__.py", line 677, in search
    ret = t.search(
  File "/Users/PERE/Developer/trainline-python/trainline/__init__.py", line 160, in search
    ret = c._post(url=_SEARCH_URL, post_data=post_data)
  File "/Users/PERE/Developer/trainline-python/trainline/__init__.py", line 88, in _post
    raise ConnectionError(
requests.exceptions.ConnectionError: Status code 403 for url https://www.trainline.eu/api/v5_1/search
{"url":"https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMADQxA6obKnNEAX6nnHQ==&cid=TIdsiBV~EcDHE_IAtNj5spBysTm5cthZiZJwl4CQQpF~~_KKIyorpuVdNaCwnDGqKoYe~WBoSxNxj9RAGo5ZD-3V1y2~GZ~Yl4leInQ7cHy6XJPiBbbL8hQFRCBcNc4&referer=HTTPS%3A%2F%2Fwww.trainline.eu%2Fapi%2Fv5_1%2Fsearch&hash=E1950F58FF4C3B67C237DE42A4D080&t=fe&s=35668&e=e4548cb61358ab5c28bc447a910ffc1e70a0207a18fa3f5a152d475e9a68687d"}

You can see it in the request response. Going to this URL it says something about your browser behavior intrigued us. So it seems that they implemented some kind of protection agains this.

pmontp19 avatar Jul 28 '22 11:07 pmontp19

Well it seems that this issue is not new, same as #20 and is from last year.

pmontp19 avatar Jul 28 '22 11:07 pmontp19

Same here, 403, no activity since long time from td, hope he will come back to his github T_T

fredtostaky avatar Apr 09 '23 10:04 fredtostaky