Changeset 42595 for titan/mediathek


Ignore:
Timestamp:
Aug 1, 2018, 12:25:18 AM (16 months ago)
Author:
obi
Message:

optimize cloudflare

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/mediathek/localhoster/cloudflare.py

    r39606 r42595  
    55from lib.net import Net
    66import lib.common as common
     7import re
    78
    89class CloudflareResolver(object):
    910    def __init__(self):
    10 #        self.net = Net(cookie_file='/mnt/network/cookies', http_debug=True, cloudflare=True)
    11         self.net = Net(cookie_file='/mnt/network/cookies', cloudflare=True)
     11        self.net = Net(cookie_file='/mnt/network/cookies', http_debug=True, cloudflare=True)
     12#        self.net = Net(cookie_file='/mnt/network/cookies', cloudflare=True)
    1213        url = str(sys.argv[1])
    1314        return self.get_answer_code(url)
    1415
    1516    def get_answer_code(self, web_url):
    16         headers = {'User-Agent': common.FF_USER_AGENT}                 
     17#        headers = {'User-Agent': common.FF_USER_AGENT}                 
     18#        headers = {'User-Agent': common.RAND_UA}
     19
     20        Domain = re.sub(r'https*:\/\/([^/]+)(\/*.*)', '\\1', web_url)
     21        headers = {'User-agent': common.FF_USER_AGENT, 'Referer': web_url, 'Host': Domain,
     22                   'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
     23                   'Content-Type': 'text/html; charset=utf-8'}
     24
    1725        html = self.net.http_GET(web_url, headers=headers).content
    1826        #html = self.request(web_url, cookie_file=/mnt/network/cookies, cloudflare=True)
     
    2129
    2230sys.stdout = CloudflareResolver()
     31
     32
Note: See TracChangeset for help on using the changeset viewer.