Browse Source

Fix cf algorythm.

tags/release_0.15.6^2
JackDandy 7 years ago
parent
commit
818e9b77ee
  1. 7
      CHANGES.md
  2. 6
      lib/cfscrape.py

7
CHANGES.md

@ -1,4 +1,9 @@
### 0.15.5 (2018-04-04 21:10:00 UTC)
### 0.15.6 (2018-04-05 01:20:00 UTC)
* Fix cf algorythm
### 0.15.5 (2018-04-04 21:10:00 UTC)
* Remove GFT torrent provider

6
lib/cfscrape.py

@ -82,7 +82,7 @@ class CloudflareScraper(Session):
raise
# Safely evaluate the Javascript expression
params['jschl_answer'] = str(int(js2py.eval_js(js)) + len(domain))
params['jschl_answer'] = str(js2py.eval_js(js) + len(domain))
# Requests transforms any request into a GET after a redirect,
# so the redirect has to be handled manually here to allow for
@ -96,8 +96,10 @@ class CloudflareScraper(Session):
def extract_js(body):
js = re.search(r'setTimeout\(function\(\){\s+(var '
's,t,o,p,b,r,e,a,k,i,n,g,f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n', body).group(1)
js = re.sub(r'a\.value = (parseInt\(.+?\)).+', r'\1', js)
js = re.sub(r'a\.value\s=\s([+]?.+?)\s?\+\s?[^\.]+\.length.*', r'\1', js)
js = re.sub(r'a\.value\s=\s(parseInt\(.+?\)).+', r'\1', js)
js = re.sub(r'\s{3,}[a-z](?: = |\.).+', '', js)
js = re.sub(r';\s+;', ';', js)
# Strip characters that could be used to exit the string context
# These characters are not currently used in Cloudflare's arithmetic snippet

Loading…
Cancel
Save