Python pyvirtualdisplay.Display() Examples
The following are 30
code examples of pyvirtualdisplay.Display().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyvirtualdisplay
, or try the search function
.
Example #1
Source File: Common.py From RENAT with Apache License 2.0 | 6 votes |
def screenshot(file_path): BuiltIn().log("WRN: This keyword is deprecated. Use `Display Capture` instead",console=True) capture_display(file_path)
Example #2
Source File: basedriver.py From cmdbac with Apache License 2.0 | 6 votes |
def save_screenshot(self, main_url, screenshot_path): try: from pyvirtualdisplay import Display display = Display(visible=0, size=(1024, 768)) display.start() from selenium import webdriver try: if '127.0.0.1' in main_url or 'localhost' in main_url: br = webdriver.Firefox() else: from selenium.webdriver.common.proxy import Proxy, ProxyType proxy = Proxy({ 'proxyType': ProxyType.MANUAL, 'httpProxy': HTTP_PROXY }) br = webdriver.Firefox(proxy=proxy) except Exception, e: LOG.exception(e) br = webdriver.Firefox() br.get(main_url) br.save_screenshot(screenshot_path) br.quit() display.stop() return screenshot_path
Example #3
Source File: foctor_core.py From centinel with MIT License | 6 votes |
def crawl_setup(tor=False, capture_path="", display_mode=0, port="9000", process_tag="1", exits="US"): tor_call = "" make_folder(capture_path) if tor is True: profile_ = setup_profile(tor=True, port=port, firebug=True, netexport=True, noscript=False, capture_path=capture_path) torrc_file = create_tor_config(port, "./torrc-" + process_tag, exits) tor_call = start_program("/usr/sbin/tor -f " + torrc_file) else: profile_ = setup_profile(firebug=True, netexport=True, noscript=False, capture_path=capture_path) display_ = Display(visible=0, size=(1024, 768)) if display_mode == 0: display_.start() binary = FirefoxBinary("./firefox/firefox") driver_ = webdriver.Firefox(firefox_profile=profile_, firefox_binary=binary) driver_.set_page_load_timeout(60) driver_.set_script_timeout(60) return driver_, display_, tor_call
Example #4
Source File: selenium_Utils.py From warriorframework with Apache License 2.0 | 6 votes |
def create_display(): """ Create a virtual display Default size is 1920x1080 as smaller resolution may cause problem in firefox """ status = True if data_Utils.get_object_from_datarepository("headless_display"): return status try: from pyvirtualdisplay import Display # Selenium has problem with firefox in virtualdisplay if resolution is low display = Display(visible=0, size=(1920, 1080)) display.start() print_info("Running in headless mode") except ImportError: print_error("pyvirtualdisplay is not installed in order " "to launch the browser in headless mode") status = False except Exception as err: print_error("Encountered Exception: {0}, while trying to launch the browser" " in headless mode".format(err)) status = False return status
Example #5
Source File: isp_data_pollution.py From isp-data-pollution with MIT License | 6 votes |
def pollute_forever(self): if self.verbose: print("""Display format: Downloading: website.com; NNNNN links [in library], H(domain)= B bits [entropy] Downloaded: website.com: +LLL/NNNNN links [added], H(domain)= B bits [entropy] """) self.open_driver() self.seed_links() self.clear_driver() if self.quit_driver_every_call: self.quit_driver() while True: # pollute forever, pausing only to meet the bandwidth requirement try: if (not self.diurnal_flag) or self.diurnal_cycle_test(): self.pollute() else: time.sleep(self.chi2_mean_std(3.,1.)) if npr.uniform() < 0.005: self.set_user_agent() # reset the user agent occasionally self.elapsed_time = time.time() - self.start_time self.exceeded_bandwidth_tasks() self.random_interval_tasks() self.every_hour_tasks() time.sleep(self.chi2_mean_std(0.5,0.2)) except Exception as e: if self.debug: print(f'.pollute() exception:\n{e}')
Example #6
Source File: funcselenium.py From django-functest with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUpClass(cls): if not cls.display_browser_window(): display_args = {'visible': False} if cls.browser_window_size is not None: # For some browsers, we need display to be bigger # than the size we want the window to be. width, height = cls.browser_window_size display_args['size'] = (width + 500, height + 500) cls.__display = Display(**display_args) cls.__display.start() # We have one driver attached to the class, re-used between test runs # for speed. Manually started driver instances (using new_browser_session) # are cleaned up at the end of an individual test. cls._cls_driver = cls._create_browser_instance() super(FuncSeleniumMixin, cls).setUpClass()
Example #7
Source File: yicai_spider.py From NewsScrapy with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self): self.display = Display(visible=0, size=(800, 600)) #为了隐藏浏览器 self.display.start() # chromedriver = "/home/youmi/Downloads/chromedriver" # self.driver = webdriver.Chrome(chromedriver) #若无display,会打开浏览器 chromedriver = "/home/ubuntu/geckodriver" self.driver = webdriver.Firefox(executable_path=chromedriver)
Example #8
Source File: crawl.py From proxy_web_crawler with MIT License | 5 votes |
def start_search(self): for socket in self.sockets: with Display(): try: self.search(socket) except Exception as e: print('%s: %s' % (type(e).__name__, str(e))) print('trying next socket...') finally: self.browser.quit() self.request_count += 1 if self.request_count > self.request_MAX: self.request_count = 0 self.scrape_sockets()
Example #9
Source File: base.py From django-ca with GNU General Public License v3.0 | 5 votes |
def setUpClass(cls): super(SeleniumTestCase, cls).setUpClass() if settings.SKIP_SELENIUM_TESTS: return if settings.VIRTUAL_DISPLAY: cls.vdisplay = Display(visible=0, size=(1024, 768)) cls.vdisplay.start() cls.selenium = WebDriver( executable_path=settings.GECKODRIVER_PATH, service_log_path=settings.GECKODRIVER_LOG_PATH ) cls.selenium.implicitly_wait(10)
Example #10
Source File: bot.py From pl-predictions-using-fifa with Mozilla Public License 2.0 | 5 votes |
def get_odds_checker_odds(match, league='premier-league'): home_team_name = constants.FLASH_SCORES_TEAM_TO_ODDS_CHECKER[match['home_team']] away_team_name = constants.FLASH_SCORES_TEAM_TO_ODDS_CHECKER[match['away_team']] odds_url = 'https://www.oddschecker.com/football/english/{}/{}-v-{}/winner'.format(league, home_team_name, away_team_name) display = Display(visible=0, size=(1024, 768)) display.start() driver = webdriver.Firefox('/usr/local/bin/') driver.get(odds_url) time.sleep(10) html_source = driver.page_source driver.quit() display.stop() soup = BeautifulSoup(html_source, 'lxml') home_team_for_soup = deslugify(home_team_name) away_team_for_soup = deslugify(away_team_name) if home_team_for_soup == 'Cardiff City': home_team_for_soup = 'Cardiff City' if away_team_for_soup == 'Cardiff City': away_team_for_soup = 'Cardiff City' home = soup.find('tr', {'data-bname': home_team_for_soup}) draw = soup.find('tr', {'data-bname': 'Draw'}) away = soup.find('tr', {'data-bname': away_team_for_soup}) home_bookies = home.get('data-best-bks') home_odds = float(home.get('data-best-dig')) draw_bookies = draw.get('data-best-bks') draw_odds = float(draw.get('data-best-dig')) away_bookies = away.get('data-best-bks') away_odds = float(away.get('data-best-dig')) return [home_bookies, draw_bookies, away_bookies], [1 / home_odds, 1 / draw_odds, 1 / away_odds]
Example #11
Source File: fridolin.py From ad-versarial with MIT License | 5 votes |
def build_virtdisplay(size): vdisp = Display(visible=0, size=size) return vdisp
Example #12
Source File: cb_spider.py From NewsScrapy with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self): self.display = Display(visible=0, size=(800, 600)) #为了隐藏浏览器 self.display.start() # self.chromedriver = "/home/youmi/Downloads/chromedriver" # self.driver = webdriver.Chrome(self.chromedriver) #若无display,会打开浏览器 chromedriver = "/home/ubuntu/geckodriver" self.driver = webdriver.Firefox(executable_path=chromedriver)
Example #13
Source File: utils.py From tor-browser-crawler with GNU General Public License v2.0 | 5 votes |
def start_xvfb(win_width=cm.DEFAULT_XVFB_WIN_W, win_height=cm.DEFAULT_XVFB_WIN_H): xvfb_display = Display(visible=0, size=(win_width, win_height)) xvfb_display.start() return xvfb_display
Example #14
Source File: headless_browser.py From centinel with MIT License | 5 votes |
def __init__(self): self.cur_path = os.path.dirname(os.path.abspath(__file__)) self.display = Display(visible=False) self.binary = None self.profile = None self.driver = None self.parsed = 0
Example #15
Source File: EyeWitness.py From EyeWitness with GNU General Public License v3.0 | 5 votes |
def single_mode(cli_parsed): display = None if cli_parsed.web: create_driver = selenium_module.create_driver capture_host = selenium_module.capture_host if not cli_parsed.show_selenium: display = Display(visible=0, size=(1920, 1080)) display.start() url = cli_parsed.single http_object = objects.HTTPTableObject() http_object.remote_system = url http_object.set_paths( cli_parsed.d, None) web_index_head = create_web_index_head(cli_parsed.date, cli_parsed.time) print('Attempting to screenshot {0}'.format(http_object.remote_system)) driver = create_driver(cli_parsed) result, driver = capture_host(cli_parsed, http_object, driver) result = default_creds_category(result) if cli_parsed.resolve: result.resolved = resolve_host(result.remote_system) driver.quit() if display is not None: display.stop() html = result.create_table_html() with open(os.path.join(cli_parsed.d, 'report.html'), 'w') as f: f.write(web_index_head) f.write(create_table_head()) f.write(html) f.write("</table><br>")
Example #16
Source File: selenium_base.py From openprescribing with MIT License | 5 votes |
def get_browser(cls): if use_saucelabs(): return cls.get_saucelabs_browser() else: if cls.use_xvfb(): from pyvirtualdisplay import Display cls.display = Display(visible=0, size=(1200, 800)) cls.display.start() return cls.get_firefox_driver()
Example #17
Source File: get_links.py From Malicious_Domain_Whois with GNU General Public License v3.0 | 5 votes |
def get_final_url(url): with Display(backend="xvfb", size=(1440, 900)): driver = webdriver.Chrome() driver.maximize_window() driver.get(url) url = driver.current_url driver.quit() return url
Example #18
Source File: weibofinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #19
Source File: pytest_xvfb.py From pytest-xvfb with MIT License | 5 votes |
def start(self): self._virtual_display = pyvirtualdisplay.Display( backend='xvfb', size=(self.width, self.height), color_depth=self.colordepth, use_xauth=self.xauth, extra_args=self.args) self._virtual_display.start() self.display = self._virtual_display.display assert self._virtual_display.is_alive()
Example #20
Source File: pinterestfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #21
Source File: facebookfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #22
Source File: linkedinfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #23
Source File: doubanfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #24
Source File: vkontaktefinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #25
Source File: instagramfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #26
Source File: Common.py From RENAT with Apache License 2.0 | 5 votes |
def start_display(): """ Starts a virtual display """ global DISPLAY display_info = get_config_value('display') logging.getLogger("easyprocess").setLevel(logging.INFO) w = int(display_info['width']) + 100 h = int(display_info['height']) + 100 DISPLAY = Display(visible=0, size=(w,h)) DISPLAY.start() time.sleep(2) BuiltIn().log('Started a virtual display as `%s`' % DISPLAY.new_display_var)
Example #27
Source File: linkedinphisher.py From social_attacker with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #28
Source File: facebookphisher.py From social_attacker with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) #self.driver.delete_all_cookies()
Example #29
Source File: twitterphisher.py From social_attacker with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #30
Source File: vkontaktephisher.py From social_attacker with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()