Esempio n. 1
0
def getHtmlToClipboard(dest_url):
    html_headers = {
        "Host": "note.youdao.com",
        "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0",
        "Accept":
        "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
        #"Accept-Encoding": "gzip, deflate, br",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Connection": "keep-alive"
    }
    try:
        html_host = urllib.parse.urlparse(dest_url)
        html_headers["Host"] = html_host.netloc
        # urllib不会自动解压缩
        #html_request = urllib.request.Request(url, headers=html_headers)
        #html_respone = urllib.request.urlopen(html_request)
        #html_respone = urllib.request.urlopen(dest_url)
        #print(html_respone.read().decode("utf-8"))
        #html_text = html_respone.read().decode("utf-8")

        html_respone = requests.get(dest_url, headers=html_headers)
        #print(html_respone.text)
        html_text = html_respone.text

        html_doc = Document(html_text)
        richxerox.pasteboard.set_contents(html=html_doc.summary())
        richxerox.copy(html=html_doc.summary())
    except Exception:
        return False
    else:
        return True
def handle_clipboard(event):
    try:
        # cb = pyperclip.paste() # root.clipboard_get() # cb = clipboard.paste() # none of them working with ó í á à
        # root.clipboard_append(cb_transformed) # clipboard.copy(cb_transformed)

        clipboard = paste()

        if not "text" in available():
            logger.info(
                f"Clipboard is not string. Available types {available()}")
            return "break"

        # logger.debug(f'{cb}')

        cb_transformed = default_transform_function(clipboard)
        copy(cb_transformed)

        text.delete("0.0", tk.END)
        text.insert("0.0", cb_transformed)
        text.insert(tk.END, "\n\n\n\n\t\t\t\tCOPIED TO CLIPBOARD")

    except Exception as e:
        logger.error(traceback.format_exc())

    return "break"
Esempio n. 3
0
    title = title.lstrip('# ').strip(' .')
    podcaster = soup.select('.name')[0].text.strip().replace(' ', '')

    url_clip = url.split('?')[0]
    content = f'''[<strong><u>{title}</u></strong>]({url_clip} ) #podcaster/{podcaster}
    #
    '''
    return content, title


content, title = get_xyz(url)
content_html = ''.join([f'<p>{c}</p>' for c in content.split('\n')])

if len(paste) > 0:
    import richxerox
    richxerox.copy(html=content_html)
    notify("小宇宙👉剪贴板", title)
else:
    client = flomo.Flomo(cookies=cookies)
    response = client.new(content_html)
    response_json = json.loads(response.text)
    if response.status_code == 200:
        if response_json['code'] == 0:
            notify("小宇宙👉flomo", title)
        else:
            print(response_json)
            notify("🚨 flomo Error", response_json['message'])
    else:
        print(response_json)
        notify("🚨 flomo Failed", response_json['message'])
Esempio n. 4
0
def copy_richxerox(text, html, rtf):
    import richxerox
    richxerox.copy(text, html=html, rtf=rtf)
Esempio n. 5
0
def copy_html(content):
    return richxerox.copy(html=content)
Esempio n. 6
0
 def copy_osx(text=None, clear_first=True, **kwargs):
     richxerox.copy(text, clear_first, **kwargs)
Esempio n. 7
0
 
 for repository in data:
     
     # Get the repo name from the last part of the URI
     name = transformers.getRepoName(repository[u'resource_uri'])
     
     # Print out if filter matches (or is not set)
     if ( options['filter'] is None ) or ( str(name).startswith(options['filter']) ):
         
         cells = []
         for output in outputs:
         
             print output['key'], "=", repository[output['key']], " ", 
             cells.append(output['transformer'](repository[output['key']]))
         
         webpage.addDataRow(cells)
         print ""
 
 if options['output'] is not None:
     ET.ElementTree(webpage.doc).write(options['output'])
     print "Output written to ", options['output']
     
 if options['copy']:
     try:
         import richxerox
         richxerox.copy( html = ET.tostring(webpage.doc))
         print('Copied HTML report to system clipboard')
     except:
         print('System copy failed or is not available.')