Skip to content

Instantly share code, notes, and snippets.

@KalenXI
Created September 17, 2023 13:28
Show Gist options
  • Save KalenXI/4dcfb8df5f72f052b241930459e33b0f to your computer and use it in GitHub Desktop.
Save KalenXI/4dcfb8df5f72f052b241930459e33b0f to your computer and use it in GitHub Desktop.
Traffic Screenshots
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
def main():
CHROME_PATH = '/usr/bin/google-chrome'
CHROMEDRIVER_PATH = '/usr/bin/chromedriver'
WINDOW_SIZE = "1920,1080"
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE)
chrome_options.binary_location = CHROME_PATH
chrome_options.add_argument("user-data-dir=selenium")
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.google.com/maps/@39.1839379,-76.7510789,10.97z/data=!5m1!1e1")
time.sleep(5)
driver.execute_script('''
const date = new Date().toLocaleString('en-US', { timeZone: 'America/New_York' });
var node=document.querySelector('#LFaNsb').innerHTML= '<div style="font-size: 20px;">' + date + '</div>';
var node=document.querySelector('.J43RCf');
node.parentNode.removeChild(node);
var node1=document.querySelector('.LfygZc');
node1.parentNode.removeChild(node1);
var node2=document.querySelector('.F63Kk');
node2.parentNode.removeChild(node2);
var node3=document.querySelector('#omnibox');
node3.parentNode.removeChild(node3);
var node3=document.querySelector('.app-vertical-widget-holder');
node3.parentNode.removeChild(node3);
var node4=document.querySelector('#gb')
node4.parentNode.removeChild(node4);
var node5=document.querySelector('#runway-expand-button');
node5.parentNode.removeChild(node5);
var node6=document.querySelector('#assistive-chips');
node6.parentNode.removeChild(node6);''')
driver.get_screenshot_as_file(f"traffic/capture {round(time.time())}.png")
driver.close()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment