Anorov / cloudflare-scrape

A Python module to bypass Cloudflare's anti-bot page.
MIT License
3.38k stars 460 forks source link

Module broken #55

Closed matoro closed 8 years ago

matoro commented 8 years ago

Module has broken for me as of 2016/06/02.

Traceback (most recent call last):
  File "/home/matoro/documents/scripting/aniwatch-getcookies.py", line 1, in <module>
    import cfscrape; cookie_arg, user_agent = cfscrape.get_cookie_string("https://kissanime.to"); print (cookie_arg)
  File "/usr/lib/python3.5/site-packages/cfscrape/__init__.py", line 152, in get_cookie_string
    tokens, user_agent = cls.get_tokens(url, user_agent=user_agent, js_engine=None)
  File "/usr/lib/python3.5/site-packages/cfscrape/__init__.py", line 124, in get_tokens
    resp = scraper.get(url)
  File "/usr/lib/python3.5/site-packages/requests/sessions.py", line 487, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3.5/site-packages/cfscrape/__init__.py", line 30, in request
    return self.solve_cf_challenge(resp, **kwargs)
  File "/usr/lib/python3.5/site-packages/cfscrape/__init__.py", line 52, in solve_cf_challenge
    js = self.extract_js(body)
  File "/usr/lib/python3.5/site-packages/cfscrape/__init__.py", line 73, in extract_js
    "t,r,a,f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n", body).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

URL of page: https://kissanime.to/ Unblocked source of the page: https://gist.githubusercontent.com/matoro/7b68ca646d74aa85be75c574b3ada52e/raw/88428631317b9446584e58a671f680e4383f088b/kissanime.html

A bit of further information: I've been using this method up until this point with no problems. It is part of a much larger bash script I'm using as a learning tool for bash. The relevant section pastes the code import cfscrape; cookie_arg, user_agent = cfscrape.get_cookie_string("https://kissanime.to"); print (cookie_arg) into aniwatch-getcookies.py, executes it, then deletes the file. I can post the complete bash script if it will help.

I have a debug mode built into the script, which will print the cookies to stdout. When running it, I get the following:

[debug] Clearance cookies [!] Unable to parse Cloudflare anti-bots page. Try upgrading cloudflare-scrape, or submit a bug report if you are running the latest version. Please read https://github.com/Anorov/cloudflare-scrape#updates before submitting a bug report.

'https://kissanime.to' returned an error. Could not collect tokens. obtained.
Coriou commented 8 years ago

Same for me

baruKV commented 8 years ago

Hi,

replace t,r,a,f with s,t,o,p,b,r,e,a,k,i,n,g,f in line 73 seems to work.

Coriou commented 8 years ago

replace t,r,a,f with s,t,o,p,b,r,e,a,k,i,n,g,f in line 73 seems to work.

I can confirm this works, thank you

Anorov commented 8 years ago

PR merged. Will upload to PyPI shortly.