source: titan/mediathek/localhoster/cloudflare.py

Last change on this file was 44474, checked in by obi, 22 months ago

fix

File size: 1.3 KB
Line 
1
2import urllib2
3from lib import helpers
4import sys
5from lib.net import Net
6import lib.common as common
7import re
8import cookielib
9#from lib.cCFScrape import cCFScrape
10#from lib.cloudflare import cloudflare
11import lib.cloudflare as cloudflare
12#from lib.cCFScrape import cCFScrape
13
14class CloudflareResolver(object):
15    def __init__(self):
16        self.net = Net(cookie_file='/mnt/network/cookies', http_debug=True, cloudflare=True)
17#        self.net = Net(cookie_file='/mnt/network/cookies', cloudflare=True)
18
19        url = str(sys.argv[1])
20        return self.get_answer_code(url)
21
22    def get_answer_code(self, web_url):
23#        headers = {'User-Agent': common.FF_USER_AGENT}                 
24#        headers = {'User-Agent': common.RAND_UA}
25
26        Domain = re.sub(r'https*:\/\/([^/]+)(\/*.*)', '\\1', web_url)
27        headers = {'User-agent': common.FF_USER_AGENT, 'Referer': web_url, 'Host': Domain,
28                   'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
29                   'Content-Type': 'text/html; charset=utf-8'}
30
31        CF = cloudflare.CloudflareBypass()
32        html = CF.GetHtml(web_url)
33        ret = self.net.save_cookies('/mnt/network/cookies')     
34
35        print CF.GetReponseInfo()
36
37        try:
38            print "html", html.encode('utf8')
39        except:
40            print html
41
42sys.stdout = CloudflareResolver()
43
Note: See TracBrowser for help on using the repository browser.