# Path: lib/timeout.py
# class Timeout():
#     """Timeout class using ALARM signal."""
#     class Timeout(Exception):
#         pass
# 
#     def __init__(self, sec):
#         self.sec = sec
# 
#     def __enter__(self):
#         signal.signal(signal.SIGALRM, self.raise_timeout)
#         signal.alarm(self.sec)
# 
#     def __exit__(self, *args):
#         signal.alarm(0)    # disable alarm
# 
#     def raise_timeout(self, *args):
#         raise Timeout.Timeout()


import sys
import requests
import config as cfg
from lib.timeout import Timeout
#!/usr/bin/env python3
# encoding: utf-8

"""
Working with webpages.

# from jplib import web
# from jplib.web import get_page
"""




headers = {
    'User-Agent': cfg.USER_AGENT,
}

MAX = 999


def get_page(url, debug=False, user_agent=True, timeout=MAX):
    try:

# Path: lib/timeout.py
# class Timeout():
#     """Timeout class using ALARM signal."""
#     class Timeout(Exception):
#         pass
# 
#     def __init__(self, sec):
#         self.sec = sec
# 
#     def __enter__(self):
#         signal.signal(signal.SIGALRM, self.raise_timeout)
#         signal.alarm(self.sec)
# 
#     def __exit__(self, *args):
#         signal.alarm(0)    # disable alarm
# 
#     def raise_timeout(self, *args):
#         raise Timeout.Timeout()


# Path: lib/web.py
import sys
import requests
import config as cfg
from lib.timeout import Timeout

#!/usr/bin/env python3
# encoding: utf-8

"""
Working with webpages.

# from jplib import web
# from jplib.web import get_page
"""




headers = {
    'User-Agent': cfg.USER_AGENT,
}

MAX = 999


def get_page(url, debug=False, user_agent=True, timeout=MAX):
    try:

        with Timeout(timeout):