def StartChrome(self, caps={}): """Creates a ChromeDriver instance. Args: caps: Capabilities that will be passed to ChromeDriver. """ self._driver = Chrome(self._service.service_url, caps)
def main(): print("Blink Container Main script") #Change the working directory to the Shared folder os.chdir(Container.homeFolder) if os.path.isfile(Container.updateFile): #We update the container subprocess.call(["python3", "/home/blink/updateContainer.py"]) else: #We create an instance of Container blink = Container() #We check the Data file with the complete user profile blink.checkDataFile() #We chose the fonts and the plugins blink.selectFonts() blink.selectPlugins() if blink.selectBrowser() == 'chrome': browser = Chrome() else: browser = Firefox() #We import the user profile inside the browser browser.importData() #We initialise a boolean to indicate if the #VM must be shutdown shutdown = False while not shutdown: #We launch the browser browserProcess = browser.runBrowser() signal.signal(signal.SIGINT, sigint_handler) #We wait for either the browsing session to be finished while not isinstance(browserProcess.poll(), int): time.sleep(1) encryption = browser.exportData() #Encrypt file if the encryption is activated if encryption: done = False while not done: res = subprocess.getstatusoutput( "gpg2 -c --cipher-algo=AES256 " + Container.dataFile) if res[0] == 0: #If the encryption went well, we removed the unencrypted file subprocess.call("rm " + Container.dataFile, shell=True) done = True elif "cancelled" in res[1]: #If the user cancelled the encryption operation, we do nothing done = True #We finish the execution of the script shutdown = True
def StartChrome(self, caps={}, options=None): """Creates a ChromeDriver instance. If both caps and options have the same settings, the settings from options will be used. Args: caps: Capabilities that will be passed to ChromeDriver. options: ChromeOptions object that will be passed to ChromeDriver. """ self._driver = Chrome(self._service.service_url, caps, options)
def log(): print e.get() number = e.get() if number == '': show_tip() else: key = Http.get_key(number) print key if key == '': show_code_error() else: print key root.withdraw() chrome = Chrome(key) chrome.open_web()
def __init__(self): self.ss = requests.session() chrome = Chrome() cookies = chrome.cookie('.baidu.com') self.ss.cookies.update(cookies) baseheaders = { 'Accept': 'application/json, text/plain, */*', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Cache-Control': 'no-cache', 'DNT': '1', 'Host': 'index.baidu.com', 'Pragma': 'no-cache', 'Referer': 'http://index.baidu.com/v2/main/index.html', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36', 'X-Requested-With': 'XMLHttpRequest', } self.ss.headers.update(baseheaders)
def __init__(self, device, mod): self.product = Configs("common").get("product", "Info") self.device = connect_device(device) self.appconfig = AppConfig("appinfo") self.logger = createlogger(mod) self.camera = Camera(self.device, "media_camera") self.record = Recorder(self.device, "media_recorder") #self.browser = Browser(self.device,"media_browser") self.chrome = Chrome(self.device, "media_chrome") if self.product == "Sprints": self.music = PlayMusic(self.device, "media_music") else: self.music = Music(self.device, "media_music") self.suc_times = 0 self.mod_cfg = GetConfigs(mod) self.test_times = 0 self.dicttesttimes = self.mod_cfg.get_test_times() for i in self.dicttesttimes: self.test_times += int(self.dicttesttimes[i]) if i.upper() in ('VIDEOTIMES', 'RECORDER', 'PHOTOTIMES'): self.test_times += int(self.dicttesttimes[i]) * 2 self.logger.info('Trace Total Times ' + str(self.test_times))
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from PIL import Image import pytesseract import os pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract' url = 'http://admin.kingxin.top' cr = Chrome(True) def save_image(image_url): file_name = 'code.png' cmd = 'wget %s -O %s' % (image_url, file_name) os.system(cmd) return file_name def image_orc(image_path): im = Image.open(image_path) ''' im=im.convert('L')#图片转换为灰色图 im=im.convert('RGBA')#图片转换成RGBA模式 pixdata = im.load()
# coding:utf-8 from http import Http from chrome import Chrome key = Http.get_key_new() print key if key == '': print "验证码错误" else: print key chrome = Chrome(key) chrome.open_web_up() input("wait....")
import time from chrome import Chrome import Page import Runtime c = Chrome() c.do(Page.navigate("http://adhocteam.us/our-team")) # if we don't wait for the page to load, then we can run the script too # early and get an empty array. # # TODO a great next step would be to figure out how to receive pageLoad # event from Page and only run the command at that time time.sleep(2) cmd = '[].map.call(document.querySelectorAll("h3.centered"), n => n.textContent)' c.do(Runtime.evaluate(cmd, returnByValue=True))
_, _, count = driver.find_element_by_xpath( '//span[@data-region="user-count-summary"]').text.split(' ') return int(count) def calificaciones(self, course): driver = self.driver driver.get(self.base + '/my/') a = driver.find_element_by_xpath( '//a[normalize-space(text())="{}"]'.format(course)) courseid = a.get_attribute('href').split('=')[1] driver.get(self.base + '/grade/export/xls/index.php?id=' + courseid) driver.find_element_by_id('id_submitbutton').click() self.chrome.download_file() def get_element_value(e): if e.get_attribute('type') == 'checkbox': return str(int(e.is_selected())) return e.get_attribute('value') if __name__ == '__main__': try: os.chdir(os.path.dirname(__file__)) except: pass with Chrome() as b: cv = CampusVirtual(b) cv.authenticate() cv.calificaciones('REDES DE COMPUTADORES I')
# -*- coding: UTF-8 -*- import time from chrome import Chrome from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC url = 'http://webmail.kingxin.top' cr = Chrome(False) def get_webmail_cookie(username, password): cr.driver.get(url) wait = WebDriverWait(cr.driver, 10) input_mail = wait.until( EC.element_to_be_clickable((By.ID, 'RainLoopEmail'))) input_mail.send_keys(username) input_pw = cr.driver.find_element_by_id('RainLoopPassword') input_pw.send_keys(password) button_login = cr.driver.find_element_by_class_name('buttonLogin') button_login.click() wait = WebDriverWait(cr.driver, 10) icon = wait.until(
def main(): print("Blink VM Main script") #Change the working directory to the Shared folder os.chdir(VM.sharedFolder) #We create an instance of a VM machine = VM() #We chose the fonts and the plugins machine.selectFonts() machine.selectPlugins() #We look for the JSON data file dataPath = VM.jsonDataFile encryptedDataPath = dataPath + ".gpg" #Decrypt file if encrypted if os.path.isfile(encryptedDataPath): cancelled = False while not os.path.isfile(dataPath) and not cancelled: res = subprocess.getstatusoutput("gpg2 -d -o " + dataPath + " " + encryptedDataPath) if res[0] != 0 and "cancelled" in res[1]: cancelled = True subprocess.call("rm " + encryptedDataPath, shell=True) #Look in the browser folder for the browser but #Execute a different command according to the browser used if os.path.isfile(VM.sharedFolder + "chrome.browser"): browser = Chrome() else: browser = Firefox() #We import the user profile inside the browser browser.importData() #We initialise a boolean to indicate if the #VM must be shutdown shutdown = False while not shutdown: #We launch the browser browserProcess = browser.runBrowser() #We wait for either the browsing session to be finished or the computer to be locked while not isinstance(browserProcess.poll(), int) and not os.path.isfile(VM.sharedFolder + "browser.switch"): time.sleep(10) encryption = browser.exportData() #If the browsing session is finished if isinstance(browserProcess.poll(), int): #Encrypt file if the encryption is activated if encryption: done = False while not done: res = subprocess.getstatusoutput( "gpg2 -c --cipher-algo=AES256 " + dataPath) if res[0] == 0: #If the encryption went well, we removed the unencrypted file subprocess.call("rm " + dataPath, shell=True) done = True elif "cancelled" in res[1]: #If the user cancelled the encryption operation, we do nothing done = True #We write a file to signal the host to shutdown all running VMs subprocess.call("touch " + VM.sharedFolder + "VM.shutdown", shell=True) #We finish the execution of the script shutdown = True else: #We terminate the browser process browserProcess.kill() #We switch the list of plugins and fonts machine.selectFonts() machine.selectPlugins() #We remove the "browser.switch" file subprocess.call("rm " + VM.sharedFolder + "browser.switch", shell=True)
from chrome import Chrome import coinmarketcap if __name__ == '__main__': chrome = Chrome() coinmarketcap.run(chrome) chrome.web.close()
context = { "assets": { "count": 5, }, "company": { "name": "Flughafen Bern AG", }, "assembly": { "name": "Generalversammlung der Flughafen Bern AG", "date": "4 Aug 2020", "address": "GV Flughafen Bern AG" }, "shareholder": { "get_full_name": "Rudy Fasel Sarl", "get_stacked_address": "Rue Pontmurre 14", }, "coupon_count": 15 } settings.configure(**SETTINGS) django.setup() p = Chrome() pdf = p.render_template("admission_card.pdf.html", context) pdf_file = open("admission_card.pdf", 'wb') pdf_file.write(pdf)