def down(url):
    h = Html(url)
    result = re.search(r'(?s)<div class="x-wiki-tree">.*?</div>', h.html).group()
    urls = re.findall(r'http://[^"]*', result)
    # for url in urls:
    #     Html(url).download()

    pool = Pool(5)
    pool.map(multiDownload, urls)
    pool.close()
    pool.join()

    h.download()
Exemple #2
0
def down(url):
    h = Html(url)
    result = re.search(r'(?s)<div class="x-wiki-tree">.*?</div>',
                       h.html).group()
    urls = re.findall(r'http://[^"]*', result)
    # for url in urls:
    #     Html(url).download()

    pool = Pool(5)
    pool.map(multiDownload, urls)
    pool.close()
    pool.join()

    h.download()
    def handle_starttag(self, tag, attrs):
        """find out <a> tag anf href attribute in that for urls"""
        import constants
        import logging
        if tag != constants.HTML_TAG_A:
            return

        attrs = dict(attrs)
        url_path = attrs[constants.HTML_TAG_A_ATTR_HREF]

        from html import Html
        from url import InvalidUrlError

        try:
            html = Html.from_url_string(url_string=url_path)
        except InvalidUrlError as e:
            logging.debug(e)

        else:
            import db

            try:
                db.add(html)
            except db.NotUniqueError as e:
                logging.debug(e)
Exemple #4
0
def send_smart():
    hostname = socket.gethostname()
    mail_info = consts.MAIL_INFO.copy()
    html_contents = Html(
        usage=disk_usage(),
        disks=disk_info(),
        smart=smart_info(),
        columns=consts.SMART_TABLE_COLUMN,
        template_path=consts.TEMPLATE_PATH
    )
    subject = '{} {} from {}'.format(consts.NAS_NAME, consts.MAIL_SUBJECT, hostname)
    body = html_contents.build_html()
    mail_dict = {
        'subject': subject,
        'body': body
    }
    mailer = Mail(mail_info)
    msg = mailer.create_message(mail_dict)
    mailer.send_mail(msg)
Exemple #5
0
def rfc2mobi(kgen, rfc, lines):
    '''
    '''
    parDir = configuration.get_default_dir()
    directory = parDir + "/" + rfc
    css_dir = configuration.get_css_dir()
    images_dir = configuration.get_images_dir()

    if not os.path.exists(directory + "/" + images_dir):
        os.makedirs(directory + "/" + images_dir)
    if not os.path.exists(directory + "/" + css_dir):
        os.makedirs(directory + "/" + css_dir)

    html_file = os.path.join(directory, rfc + '.html')

    output = open(html_file, 'w')

    html = Html(directory, css_dir, images_dir, rfc, lines, output)
    html.createHTML()

    src_css_files = os.listdir(configuration.get_css_src_dir())
    for file_name in src_css_files:
        full_file_name = os.path.join(configuration.get_css_src_dir(),
                                      file_name)
        if (os.path.isfile(full_file_name)):
            shutil.copy(full_file_name, directory + "/" + css_dir)

    output.close()

    #using kindlegen binary to create .mobi file
    exitCode = subprocess.call([kgen, html_file, '-o', rfc + '.mobi'])

    #1 or 0 means warnings or success
    if exitCode >= 2:
        print("Fatal error while processing ", rfc)
        print("Deleting attempted directory ", directory)
        shutil.rmtree(directory)
    else:
        print("Successfully converted ", rfc, " into ", rfc, " directory.")
class Player:

    extra_links = []

    def __init__(self):

        self.browser = Browser()
        self.html = Html()
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(os.getcwd(), '../gui/src/player.glade'))
        self.win = self.builder.get_object('mainWindow')
        self.win.set_size_request(860, 600)

        self.win.set_resizable(False)
        self.mainBox = self.builder.get_object('mainBox')
        self.mainBox.set_size_request(800, 600)
        self.left = self.builder.get_object('left')
        self.win.connect("window-state-event", self.on_window_state_event)
        self.win.connect('destroy', Gtk.main_quit)
        self.win.connect('delete-event', Gtk.main_quit)
        self.win.set_icon_from_file(Helper.get_resource_path("icon.png"))
        self.left_handler()

    def on_window_state_event(self, widget, event, data=None):
        mask = Gdk.WindowState.FULLSCREEN
        fullscreen = widget.get_window().get_state() & mask == mask

        if fullscreen:
            self.mainBox.set_homogeneous(True)
        else:
            self.mainBox.set_homogeneous(False)

    def set_title(self, title):
        self.win.set_title(title)

    def set_links(self, links):
        self.extra_links = links[:]

    def left_handler(self):
        browser = self.browser.get()
        self.left.add(browser)

    def link_clicked(self, widget, link):
        self.browser.open(link)

    def open(self, url):
        movie = self.html.create(url)
        self.browser.open(movie)
        self.win.show_all()
 def __init__(self, db_beacon_web_application, db_beacon_api, env):
     self.db_beacon_web_application = db_beacon_web_application
     self.db_beacon_api = db_beacon_api
     self.env = env
     self.html = Html(self)
     self.url_service = Url(
         self.db_beacon_web_application.get_field("url shortener"),
         self.db_beacon_web_application.get_field("url shortener key"))
     self.selected_beacon = None
     self.identifier = self.db_beacon_web_application.get_field(
         "identifier")
     self.picture_identifier = self.db_beacon_web_application.get_field(
         "picture identifier")
     self.form_template = self.db_beacon_web_application.get_field("form")
     self.table_template = self.db_beacon_web_application.get_field("table")
     self.fields = self.create_fields(self.form_template)
     self.readonly = self.db_beacon_web_application.get_field("read-only")
     self.room_finder = self.db_beacon_web_application.get_field(
         "roomfinder")
     self.advertisement_rate = self.db_beacon_web_application.get_field(
         "advertisement rate")
     self.transmission_power = self.db_beacon_web_application.get_field(
         "transmission power")
     self.drop_down_fields_transmission_power = self.db_beacon_web_application.get_field(
         "drop down transmission power")
     self.drop_down_fields_advertisement_rate = self.db_beacon_web_application.get_field(
         "drop down advertisement rate")
     self.image_path = self.db_beacon_web_application.get_field(
         "image path")
     self.advertisement_rate_converter = self.db_beacon_web_application.get_field(
         "advertisement rate converter")
     self.transmission_power_converter = self.db_beacon_web_application.get_field(
         "transmission power converter")
     self.advertisement_rate_converter_fields = self.db_beacon_web_application.get_field(
         "advertisement rate converter fields")
     self.transmission_power_converter_fields = self.db_beacon_web_application.get_field(
         "transmission power converter fields")
     self.maintenance_field = self.db_beacon_web_application.get_field(
         "maintenance field", "web api")
     self.timestamp_field = self.db_beacon_web_application.get_field(
         "timestamp field", "web api")
     self.len_s_beacon_id = self.db_beacon_web_application.get_field(
         "len s beacon id")
     self.action_update_beacon = "/update_beacon/"
     self.action_edit_beacon = "/edit_beacon/"
     self.newline = self.db_beacon_web_application.get_field("newline")
     self.update_action = False
     self.status = ""
     self.aes_cipher = AESCipher.keyFromVariable(utils.encryption.key)
    def __init__(self):

        self.browser = Browser()
        self.html = Html()
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(os.getcwd(), '../gui/src/player.glade'))
        self.win = self.builder.get_object('mainWindow')
        self.win.set_size_request(860, 600)

        self.win.set_resizable(False)
        self.mainBox = self.builder.get_object('mainBox')
        self.mainBox.set_size_request(800, 600)
        self.left = self.builder.get_object('left')
        self.win.connect("window-state-event", self.on_window_state_event)
        self.win.connect('destroy', Gtk.main_quit)
        self.win.connect('delete-event', Gtk.main_quit)
        self.win.set_icon_from_file(Helper.get_resource_path("icon.png"))
        self.left_handler()
Exemple #9
0
def multiDownload(url):
    """多线程方法"""
    Html(url).download()
def parse_status_html(nagios_status_html_str, time_format='%m-%d-%Y %H:%M:%S'):
    rows = Html(nagios_status_html_str).cssselect('table.status > tr')
    for row in rows[1:]:
        res = parse_status_html_row(time_format, row)
        if res:
            yield res
header = {
          'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3',
'Connection':'keep-alive',
'Cookie':"__utma=243156864.1660532569.1377423359.1380900067.1380937282.6; __utmz=243156864.1380900067.5.3.utmcsr=baidu|utmccn=(organic)|utmcmd=organic|utmctr=sogotrade%20%E6%89%8B%E6%9C%BA; PSSO=%09%c3%a5%c2%aa-%c3%b9%60%c2%8dQ%c3%96c%c2%adZ%c3%94%19%c2%b3%e2%80%9c%16%c3%a2%c3%b4%c2%a7%25%e2%80%9dg%e2%80%a1%c3%973%c3%a5H%e2%84%a2%c3%bfS%1bo%22%3e%c3%95%17B%c3%98K%13%c3%8b%c6%92O%e2%80%98%c5%beob%c3%bf%22y%3e%5c%1eu%0ck%5c%10%23%c3%95%5bq%e2%80%a6%e2%80%98%c3%81!%c2%a5%3fp67%02%0e%c3%83%c2%a1%e2%80%9a%c3%9cY5%c2%bd%c5%a1%c2%aa%e2%80%98_4%c3%8c%c3%be%c3%99%c2%b9%c3%a7%c3%ac%c3%89%60%40%c3%b9HbW%c3%afq%c3%b7%c2%a3k%0a%0c%c3%80%c3%bc%1eG%16%c3%86%e2%84%a2%184V%c2%a3.q%c5%a1%e2%84%a2%09%e2%80%98%e2%80%9c%c3%971%c3%b6%c2%ad%c2%bfum%03%c3%a15%c3%9dZ%05%c3%a5H%c2%ba%c2%aaW%c2%a1%c2%b5%c2%ab%c3%b9f%c3%94%c2%b9%c3%a8%c3%af%c3%93%c3%99%e2%80%9ey%c3%b7E%05%c2%bb%c3%9e%e2%80%9a%07%257W%c3%ad%c3%9da%c3%ab%c2%a6%c3%a0%19%7d%c3%bc1%c2%ae%23%c2%bb%c2%a4%c3%9b%c2%8fD%c3%be%5b%1aPu8W7%0f%c3%99%11%02%00O%c3%a4jq%c2%be%07%c3%a5%c2%b0%c3%b2%c3%9a%c2%aa%c3%8d%40%c3%96%c2%bf%c2%bd%c3%aa%c3%b2%e2%80%93%11%c2%8fUh%c2%a0k%c3%b4%10%3dC%1a%c2%ac%c3%97%5e%c3%a9Rb%02%00%c3%a1%c5%a0%c2%a8rSOg%c3%afH'%c2%aeU%c2%bc%c2%a2%c3%a1%16Fa%15%00%c3%80%c3%93%c2%a6; __utmc=243156864; BureauSwitcher=SOGO; ASP.NET_SessionId=xnr3eggz0qu5h0bb1u1as2ik; TradeBottomTabIndex=0; activeSettingPageIndex=0; activeSettingLinkIndex=7; ctl00_mc_ac_QuickQuotePane_QuickQuote1_stockChartGOOG=0; StockSelectAuthCookie=304528A8B083E3E772E22662F4C99DA8E72A0D67F3F75CF5000F6EA223D9CC0E9B76551EE7871F0FFBB1EF474DF00054668CF4A8CC2A8E288A65746E333D925BDC804CE2956D602A288D9D2A1CE618DDC8E3BD2C2360D17D2A72AB88B13714AB88D347F96D538E9FF678002B59DD87BCE4000D49E70AA928E07B0B0FB6A208A6ED9D81CF44D5313C053DBE3505F02EAAEE084428; UserCulture=zh-cn; CurrentCulture=en-us",
'Host':'options.sogotrade.com',
'Referer':'https://stp.sogotrade.com/Trade.aspx?',
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; rv:23.0) Gecko/20100101 Firefox/23.0'
          }

post = {
        'chainType':'2',
'expiration':'"131221R"',
'isRotated':'false',
'showBinary':'true',
'showNonStandard':'true',
'strike':'null',
'strikes':'null',
'strikesRange':'"1"',
'underlyingSymbol':'"BIDU"'
        }

urlHandle = Html()

url = 'http://options.sogotrade.com/Chain.aspx'

url = 'https://options.sogotrade.com/Trade.aspx'

print urlHandle.get(url,header)
Exemple #12
0
 def sso(self):
     crm = Html()
     crm.post(self.url,self.params,"")
     return crm
Exemple #13
0
from html import Html
import json

url = 'http://api.map.baidu.com/?qt=bd&c=131&wd=%E5%85%AC%E4%BA%A4%E8%BD%A6%E7%AB%99&ar=(12951331.56%2C4850348.73%3B12952531.6%2C4851548.59)&rn=10&l=18&key=&ie=utf-8&oue=1&res=api&callback=BMap.DataMgr.RawDispatcher._cbk49467'

htmlHandle = Html()
a = json.loads(htmlHandle.get(url,'').split('cbk49467(')[1][:-1])
#print json.dumps(a, indent=1)
print a['content'][0]['addr']
Exemple #14
0
#coding:utf-8
from html import Html

gjLogin = '******'

gj = Html()
gj.get(gjLogin,'')
params = {
          'next':'',
            'no_cookie_test':'1',
            'password':'******',
            'username':'******'
          }
print gj.post(gjLogin,params,'')

Login58 = 'https://passport.58.com/dounionlogin'
gj.clear()
gj = Html()
gj.get(Login58,'')
params = {
          'cd':'8231',
'isweak':'0',
'mcresult':'186210094',
'p1':'3b5097066bf8c23328f2705cf7e22978',
'p2':'0935f368d58dc668582876b25a03c042',
'p3':'6171355f65ac657b8497d91ae0954c0a68bd7a711f169186fc6f2e0c43ba87d9a88fc591a90d541ffd04257ed6fb5629d6dc527097cae53d1ed3180baf456c57d87f6ad8548d54a6dffe12f1c0781a0007825cdc7e0c56a571af05da2ba6892c19ca0515221026063dbdba82891258c5c15443f342261fe6c25ee0bc9a0b422e',
'password':'******',
'path':'http://sy.58.com/?pts=1377088972251',
'ptk':'b4914e19797147beaef723f64d415fb2',
'timesign':'1377088999501',
'username':'******'
 def convert(self):
     body = self.body
     body = body.replace("\r\n", "")
     uBody = self.toUnicode(body)
     h = Html(uBody)
     return h.parse()
Exemple #16
0
    'Connection':
    'keep-alive',
    'Cookie':
    "__utma=243156864.1660532569.1377423359.1380900067.1380937282.6; __utmz=243156864.1380900067.5.3.utmcsr=baidu|utmccn=(organic)|utmcmd=organic|utmctr=sogotrade%20%E6%89%8B%E6%9C%BA; PSSO=%09%c3%a5%c2%aa-%c3%b9%60%c2%8dQ%c3%96c%c2%adZ%c3%94%19%c2%b3%e2%80%9c%16%c3%a2%c3%b4%c2%a7%25%e2%80%9dg%e2%80%a1%c3%973%c3%a5H%e2%84%a2%c3%bfS%1bo%22%3e%c3%95%17B%c3%98K%13%c3%8b%c6%92O%e2%80%98%c5%beob%c3%bf%22y%3e%5c%1eu%0ck%5c%10%23%c3%95%5bq%e2%80%a6%e2%80%98%c3%81!%c2%a5%3fp67%02%0e%c3%83%c2%a1%e2%80%9a%c3%9cY5%c2%bd%c5%a1%c2%aa%e2%80%98_4%c3%8c%c3%be%c3%99%c2%b9%c3%a7%c3%ac%c3%89%60%40%c3%b9HbW%c3%afq%c3%b7%c2%a3k%0a%0c%c3%80%c3%bc%1eG%16%c3%86%e2%84%a2%184V%c2%a3.q%c5%a1%e2%84%a2%09%e2%80%98%e2%80%9c%c3%971%c3%b6%c2%ad%c2%bfum%03%c3%a15%c3%9dZ%05%c3%a5H%c2%ba%c2%aaW%c2%a1%c2%b5%c2%ab%c3%b9f%c3%94%c2%b9%c3%a8%c3%af%c3%93%c3%99%e2%80%9ey%c3%b7E%05%c2%bb%c3%9e%e2%80%9a%07%257W%c3%ad%c3%9da%c3%ab%c2%a6%c3%a0%19%7d%c3%bc1%c2%ae%23%c2%bb%c2%a4%c3%9b%c2%8fD%c3%be%5b%1aPu8W7%0f%c3%99%11%02%00O%c3%a4jq%c2%be%07%c3%a5%c2%b0%c3%b2%c3%9a%c2%aa%c3%8d%40%c3%96%c2%bf%c2%bd%c3%aa%c3%b2%e2%80%93%11%c2%8fUh%c2%a0k%c3%b4%10%3dC%1a%c2%ac%c3%97%5e%c3%a9Rb%02%00%c3%a1%c5%a0%c2%a8rSOg%c3%afH'%c2%aeU%c2%bc%c2%a2%c3%a1%16Fa%15%00%c3%80%c3%93%c2%a6; __utmc=243156864; BureauSwitcher=SOGO; ASP.NET_SessionId=xnr3eggz0qu5h0bb1u1as2ik; TradeBottomTabIndex=0; activeSettingPageIndex=0; activeSettingLinkIndex=7; ctl00_mc_ac_QuickQuotePane_QuickQuote1_stockChartGOOG=0; StockSelectAuthCookie=304528A8B083E3E772E22662F4C99DA8E72A0D67F3F75CF5000F6EA223D9CC0E9B76551EE7871F0FFBB1EF474DF00054668CF4A8CC2A8E288A65746E333D925BDC804CE2956D602A288D9D2A1CE618DDC8E3BD2C2360D17D2A72AB88B13714AB88D347F96D538E9FF678002B59DD87BCE4000D49E70AA928E07B0B0FB6A208A6ED9D81CF44D5313C053DBE3505F02EAAEE084428; UserCulture=zh-cn; CurrentCulture=en-us",
    'Host':
    'options.sogotrade.com',
    'Referer':
    'https://stp.sogotrade.com/Trade.aspx?',
    'User-Agent':
    'Mozilla/5.0 (Windows NT 6.1; rv:23.0) Gecko/20100101 Firefox/23.0'
}

post = {
    'chainType': '2',
    'expiration': '"131221R"',
    'isRotated': 'false',
    'showBinary': 'true',
    'showNonStandard': 'true',
    'strike': 'null',
    'strikes': 'null',
    'strikesRange': '"1"',
    'underlyingSymbol': '"BIDU"'
}

urlHandle = Html()

url = 'http://options.sogotrade.com/Chain.aspx'

url = 'https://options.sogotrade.com/Trade.aspx'

print urlHandle.get(url, header)
Exemple #17
0
#coding:utf-8
from html import Html

gjLogin = '******'

gj = Html()
gj.get(gjLogin, '')
params = {
    'next': '',
    'no_cookie_test': '1',
    'password': '******',
    'username': '******'
}
print gj.post(gjLogin, params, '')

Login58 = 'https://passport.58.com/dounionlogin'
gj.clear()
gj = Html()
gj.get(Login58, '')
params = {
    'cd': '8231',
    'isweak': '0',
    'mcresult': '186210094',
    'p1': '3b5097066bf8c23328f2705cf7e22978',
    'p2': '0935f368d58dc668582876b25a03c042',
    'p3':
    '6171355f65ac657b8497d91ae0954c0a68bd7a711f169186fc6f2e0c43ba87d9a88fc591a90d541ffd04257ed6fb5629d6dc527097cae53d1ed3180baf456c57d87f6ad8548d54a6dffe12f1c0781a0007825cdc7e0c56a571af05da2ba6892c19ca0515221026063dbdba82891258c5c15443f342261fe6c25ee0bc9a0b422e',
    'password': '******',
    'path': 'http://sy.58.com/?pts=1377088972251',
    'ptk': 'b4914e19797147beaef723f64d415fb2',
    'timesign': '1377088999501',