Skip to content

Instantly share code, notes, and snippets.

@netmarkjp
Created September 14, 2012 14:46
Show Gist options
  • Save netmarkjp/3722354 to your computer and use it in GitHub Desktop.
Save netmarkjp/3722354 to your computer and use it in GitHub Desktop.
screenshot by selenium
#!/usr/bin/env python
#coding: utf-8
import selenium
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
def main():
profile=FirefoxProfile()
profile.set_preference("general.useragent.override",
"Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3")
browser=webdriver.Firefox(profile)
browser.set_window_size(320,480)
browser.get('http://www.yahoo.co.jp/')
browser.save_screenshot('screen.png')
browser.quit()
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment