-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcookie.py
More file actions
40 lines (26 loc) · 1.06 KB
/
Copy pathcookie.py
File metadata and controls
40 lines (26 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding:utf-8 -*-
from .pyrunjs import PyRunJS
class Cookie():
def __init__(self,miniblink):
self.mb=miniblink
self.js=PyRunJS(miniblink)
def wkeGetCookieW(self,webview):
return self.mb.wkeGetCookieW(webview)
def wkeSetCookie(self,webview,url,cookie):
cookie=cookie.split(';')
for x in cookie:
self.mb.wkeSetCookie(webview,url.encode('utf8'),x.encode('utf8'))
self.mb.wkePerformCookieCommand(webview,2)
def set_cookie_by_js(self,webview,url,cookie):
js_code=f"var cookie='{cookie}';"+'''
cookie.split(';').forEach(function(e){
document.cookie=e
})'''
self.js.run_js(webview,js_code)
self.mb.wkeLoadURLW(webview, url)
def wkeSetCookieJarPath(self,webview,path):
self.mb.wkeSetCookieJarPath(webview,path)
def wkeSetCookieJarFullPath(self,webview,path):
self.mb.wkeSetCookieJarFullPath(webview,path)
def wkeClearCookie(self,webview):
self.mb.wkeClearCookie(webview)