Ejemplo n.º 1
0
def load_site_internal(url,
                       session,
                       post=None,
                       options=False,
                       headers=None,
                       cookies=None):

    if post:
        response = session.post(url,
                                headers=headers,
                                cookies=cookies,
                                data=post,
                                verify=certifi.where())
    elif options:
        response = session.options(url,
                                   headers=headers,
                                   cookies=cookies,
                                   verify=certifi.where())
    else:
        response = session.get(url,
                               headers=headers,
                               cookies=cookies,
                               verify=certifi.where())

    content = response.content
    return content
Ejemplo n.º 2
0
def load_site_internal(url, session, post=None, options=False, headers=None, cookies=None):

    if post:
        response = session.post(url, headers=headers, cookies=cookies, data=post, verify=certifi.where())
    elif options:
        response = session.options(url, headers=headers, cookies=cookies, verify=certifi.where())
    else:
        response = session.get(url, headers=headers, cookies=cookies, verify=certifi.where())

    content = response.content
    return content
Ejemplo n.º 3
0
def new_session():
    global session
    session = requests.Session()
    session.headers.update({'User-Agent': 'User-Agent: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'})
    session.max_redirects = 5
    session.allow_redirects = True
    session.verify = certifi.where()
    if xbmcvfs.exists(utility.session_file()):
        file_handler = xbmcvfs.File(utility.session_file(), 'rb')
        content = file_handler.read()
        file_handler.close()
        session = pickle.loads(content)
Ejemplo n.º 4
0
def new_session():
    global session
    session = requests.Session()
    session.headers.update({
        'User-Agent':
        'User-Agent: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'
    })
    session.max_redirects = 5
    session.allow_redirects = True
    session.verify = certifi.where()
    if xbmcvfs.exists(utility.session_file()):
        file_handler = xbmcvfs.File(utility.session_file(), 'rb')
        content = file_handler.read()
        file_handler.close()
        session = pickle.loads(content)
Ejemplo n.º 5
0
def load_site(url, headers=None, post=None, options=False, cookies=None):
    utility.log('Loading url: ' + url)
    try:
        if post:
            response = session.post(url,
                                    headers=headers,
                                    cookies=cookies,
                                    data=post,
                                    verify=certifi.where())
        elif options:
            response = session.options(url,
                                       headers=headers,
                                       cookies=cookies,
                                       verify=certifi.where())
        else:
            response = session.get(url,
                                   headers=headers,
                                   cookies=cookies,
                                   verify=certifi.where())
    except AttributeError:
        utility.log('Session is missing', loglevel=xbmc.LOGERROR)
        utility.notification(utility.get_string(30301))
        new_session()
        save_session()
        if post:
            response = session.post(url,
                                    headers=headers,
                                    cookies=cookies,
                                    data=post,
                                    verify=certifi.where())
        elif options:
            response = session.options(url,
                                       headers=headers,
                                       cookies=cookies,
                                       verify=certifi.where())
        else:
            response = session.get(url,
                                   headers=headers,
                                   cookies=cookies,
                                   verify=certifi.where())
    return response.content