代码拉取完成,页面将自动刷新
同步操作将从 vintnee/cloudnote 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#! /usr/bin/python
#encoding=utf-8
#author: fakir
import oauth2 as oauth
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
from config import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWebKit import *
from PyQt5.QtNetwork import *
class AuthorizeWidget(QDialog):
def __init__(self, authorize_url, parent=None):
QDialog.__init__(self, parent)
self.authorize_url = authorize_url
self.setWindowTitle(APP_NAME)
self.layout = QHBoxLayout()
self.webView = QWebView(self)
self.layout.addWidget(self.webView)
self.layout.setSpacing(0)
self.layout.setMargin(0)
self.setLayout(self.layout)
self.setFixedWidth(290)
self.setFixedHeight(290)
self.verifier = ""
def loadAuthorize(self):
self.webView.load(QUrl(self.authorize_url))
self.connect(self.webView, SIGNAL("loadFinished(bool)"), self.loadFinished)
def loadFinished(self, finished):
frame = self.webView.page().currentFrame()
url = frame.url().toString()
print "url: ", url
doc = frame.documentElement()
if url.startsWith("http://account.youdao.com/login"): #初始登陆界面
doc.findFirst("div[id=t]").removeFromDocument()
doc.findFirst("div[id=b]").removeFromDocument()
doc.findFirst("div[class=login_left]").removeFromDocument()
content = doc.findFirst("div[id=login]")
content.setStyleProperty("position", "fixed")
content.setStyleProperty("width", "100px")
content.setStyleProperty("padding", "0px")
login = doc.findFirst("div[class=login_right]")
login.setStyleProperty("float", "none")
elif url.startsWith("http://note.youdao.com/oauth/authorize_handler"): #登陆成功确认界面
doc.findFirst("button[id=auth-btn]").evaluateJavaScript("this.click()")
elif url == "http://note.youdao.com/oauth/authorize":
text = doc.toPlainText()
print "text: ", text
reg = QRegExp("[0-9]{4,}")
pos = reg.indexIn(text, 0)
if pos != -1:
self.verifier = str(reg.cap(0))
self.close()
@staticmethod
def getVerifier(url):
w = AuthorizeWidget(url)
w.loadAuthorize()
w.exec_()
return w.verifier
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。