Last active
December 2, 2015 02:49
-
-
Save fiorix/dcceb49fb201fe5c218f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import time | |
from getopt import getopt | |
from PIL import Image | |
from selenium import webdriver | |
def capture(conf): | |
profile = webdriver.FirefoxProfile() | |
profile.set_preference("network.http.phishy-userpass-length", 255) | |
driver = webdriver.Firefox(firefox_profile=profile) | |
driver.get(conf["url"]) | |
webdriver.ActionChains(driver).move_by_offset(0, 0).perform() | |
time.sleep(int(conf["sleep"])) | |
driver.save_screenshot(conf["out"]) | |
driver.quit() | |
img = Image.open(conf["out"]) | |
(w, h) = img.size | |
area = img.crop((0, 0, w-10, h)) | |
area.save(conf["out"], conf["fmt"]) | |
def main(): | |
conf = { | |
"url": "https://freegeoip.net", | |
"sleep": "2", | |
"out": "out.png", | |
"fmt": "png", | |
} | |
args = "url= sleep= out= fmt=".split() | |
optlist, args = getopt(sys.argv[1:], "", args) | |
for k, v in optlist: | |
conf[k.lstrip("--")] = v | |
capture(conf) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment