Take a screenshot using PhantomJS with Python3 on FreeBSD

텔레그램으로 스샷을 찍어 봅시다

 

                from selenium import webdriver
                today = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
                imageName = "./images/%s_%s.png" % (today, chat_id)

                driver = webdriver.PhantomJS()
                driver.set_window_size(1024, 768)
                log.debug(keyword[1] + " => " + imageName)
                driver.get(keyword[1])  # this works fine
                driver.save_screenshot(imageName)
                driver.quit()

                fp = open(imageName, 'rb')
                self.sendPhoto(chat_id,fp)