File:Map 11 dynmap as of 24 07 2022 marked.png: Difference between revisions
Content added Content deleted
No edit summary |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
== Summary == |
== Summary == |
||
Map 11 2D Dynmap as of July 24th, 2022. Towns marked. Generated using Python script, Selenium package involved. In order to take the screenshot of the page, the Firefox browser window, which was used in this instance, was loaded on a resolution higher than the one supported by the monitor (Mixarium's monitor as he generated the image). The code below used to work, until a few days later when the default zoom level of the Puucraft dynmap changed, which will now screenshot a small part of the dynmap instead. |
Map 11 2D Dynmap as of July 24th, 2022. Towns marked. Generated using Python script, Selenium package involved. In order to take the screenshot of the page, the Firefox browser window, which was used in this instance, was loaded on a resolution higher than the one supported by the monitor ([[Mixarium]]'s monitor as he generated the image). The code below used to work, until a few days later when the default zoom level of the Puucraft dynmap changed, which will now screenshot a small part of the dynmap instead. |
||
<nowiki> |
|||
<syntaxhighlight lang="python" line="1"> |
|||
from selenium import webdriver |
from selenium import webdriver |
||
from selenium.webdriver.common.by import By |
from selenium.webdriver.common.by import By |
||
Line 7: | Line 8: | ||
def screenshot_dynmap(): |
def screenshot_dynmap(): # main function defined |
||
options = webdriver.FirefoxOptions() |
options = webdriver.FirefoxOptions() |
||
options.headless = True |
options.headless = True |
||
Line 13: | Line 14: | ||
options.add_argument("-no-sandbox") |
options.add_argument("-no-sandbox") |
||
options.add_argument("--width=2700") |
options.add_argument("--width=2700") |
||
options.add_argument("--height=2700") |
options.add_argument("--height=2700") # width and height of 2700x2700 |
||
with webdriver.Firefox(options=options) as driver: |
with webdriver.Firefox(options=options) as driver: |
||
action = webdriver.ActionChains(driver) |
action = webdriver.ActionChains(driver) |
||
driver.get('https://betadynmap.puucraft.net/#') |
driver.get('https://betadynmap.puucraft.net/#') # enter the dynmap website |
||
time.sleep(2) |
time.sleep(2) |
||
sidebar = driver.find_element(By.CSS_SELECTOR, ".hitbar") |
sidebar = driver.find_element(By.CSS_SELECTOR, ".hitbar") |
||
action.move_to_element(sidebar).perform() |
action.move_to_element(sidebar).perform() # opening the sidebar |
||
switch_to_2d = driver.find_element(By.CLASS_NAME, "maptype") |
switch_to_2d = driver.find_element(By.CLASS_NAME, "maptype") |
||
switch_to_2d.click() |
switch_to_2d.click() # page defaults to 3D Dynmap, so I had to switch to the 2D Dynmap |
||
action.move_by_offset(-1000, -1000).perform() |
action.move_by_offset(-1000, -1000).perform() |
||
time.sleep(20) |
time.sleep(20) # wait for dynmap to load the chunks |
||
driver.save_screenshot("map_11_dynmap.png") |
driver.save_screenshot("map_11_dynmap.png") # save a screenshot of the dynmap page |
||
screenshot_dynmap() |
screenshot_dynmap() |
||
</syntaxhighlight> |
Latest revision as of 07:07, 28 July 2022
Summary[edit | edit source]
Map 11 2D Dynmap as of July 24th, 2022. Towns marked. Generated using Python script, Selenium package involved. In order to take the screenshot of the page, the Firefox browser window, which was used in this instance, was loaded on a resolution higher than the one supported by the monitor (Mixarium's monitor as he generated the image). The code below used to work, until a few days later when the default zoom level of the Puucraft dynmap changed, which will now screenshot a small part of the dynmap instead.
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
def screenshot_dynmap(): # main function defined
options = webdriver.FirefoxOptions()
options.headless = True
options.add_argument("-disable-gpu")
options.add_argument("-no-sandbox")
options.add_argument("--width=2700")
options.add_argument("--height=2700") # width and height of 2700x2700
with webdriver.Firefox(options=options) as driver:
action = webdriver.ActionChains(driver)
driver.get('https://betadynmap.puucraft.net/#') # enter the dynmap website
time.sleep(2)
sidebar = driver.find_element(By.CSS_SELECTOR, ".hitbar")
action.move_to_element(sidebar).perform() # opening the sidebar
switch_to_2d = driver.find_element(By.CLASS_NAME, "maptype")
switch_to_2d.click() # page defaults to 3D Dynmap, so I had to switch to the 2D Dynmap
action.move_by_offset(-1000, -1000).perform()
time.sleep(20) # wait for dynmap to load the chunks
driver.save_screenshot("map_11_dynmap.png") # save a screenshot of the dynmap page
screenshot_dynmap()
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 08:15, 25 July 2022 | 2,700 × 2,603 (8.39 MB) | Mixarium (talk | contribs) |
You cannot overwrite this file.
File usage
The following 2 pages use this file: