|
|
@ -1,4 +1,5 @@
|
|
|
|
# coding=utf-8
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
|
|
|
|
|
|
import certifi
|
|
|
|
import certifi
|
|
|
|
import ssl
|
|
|
|
import ssl
|
|
|
|
import os
|
|
|
|
import os
|
|
|
@ -8,7 +9,9 @@ import requests
|
|
|
|
import xmlrpclib
|
|
|
|
import xmlrpclib
|
|
|
|
import dns.resolver
|
|
|
|
import dns.resolver
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from collections import OrderedDict
|
|
|
|
from requests import exceptions
|
|
|
|
from requests import exceptions
|
|
|
|
|
|
|
|
from requests.utils import default_user_agent
|
|
|
|
from urllib3.util import connection
|
|
|
|
from urllib3.util import connection
|
|
|
|
from retry.api import retry_call
|
|
|
|
from retry.api import retry_call
|
|
|
|
from exceptions import APIThrottled
|
|
|
|
from exceptions import APIThrottled
|
|
|
@ -61,13 +64,18 @@ class CertifiSession(TimeoutSession):
|
|
|
|
class CFSession(CloudflareScraper, CertifiSession, TimeoutSession):
|
|
|
|
class CFSession(CloudflareScraper, CertifiSession, TimeoutSession):
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
super(CFSession, self).__init__()
|
|
|
|
super(CFSession, self).__init__()
|
|
|
|
self.headers.update({
|
|
|
|
self.headers = OrderedDict([
|
|
|
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
|
|
('User-Agent', default_user_agent()),
|
|
|
|
'Accept-Language': 'en-US,en;q=0.5',
|
|
|
|
('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
|
|
|
|
'Cache-Control': 'no-cache',
|
|
|
|
('Accept-Language', 'en-US,en;q=0.5'),
|
|
|
|
'Pragma': 'no-cache',
|
|
|
|
('Accept-Encoding', 'gzip, deflate'),
|
|
|
|
'DNT': '1'
|
|
|
|
('Connection', 'keep-alive'),
|
|
|
|
})
|
|
|
|
('Pragma', 'no-cache'),
|
|
|
|
|
|
|
|
('Cache-Control', 'no-cache'),
|
|
|
|
|
|
|
|
('Upgrade-Insecure-Requests', '1'),
|
|
|
|
|
|
|
|
('DNT', '1'),
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
self.debug = os.environ.get("CF_DEBUG", False)
|
|
|
|
|
|
|
|
|
|
|
|
def request(self, method, url, *args, **kwargs):
|
|
|
|
def request(self, method, url, *args, **kwargs):
|
|
|
|
parsed_url = urlparse(url)
|
|
|
|
parsed_url = urlparse(url)
|
|
|
|