Selenium Checks If Number Is Even
import time from selenium.webdriver import ( Firefox, FirefoxOptions ) def headless_firefox(): opts = FirefoxOptions() opts.set_headless() return Firefox(options=opts) def is_even(n: int) -> bool: browser = headless_firefox() browser.get(f"https://www.wolframalpha.com/input/?i={n}") time.sleep(10) elems = browser.find_elements_by_xpath("//img") n_is_even = False for img in elems: if "is an even number" in img.get_attribute('alt'): n_is_even = True break browser.close() return n_is_even
A dark-themed Python code screenshot shows Selenium launching a headless Firefox browser, querying WolframAlpha for a number, and inspecting image alt text to determine whether the number is even. The joke is the absurdly overcomplicated approach to a trivial parity check, making it a reaction to unnecessarily complex code or overengineering. EN: A dark-themed Python code screenshot shows Selenium launching a headless Firefox browser, querying WolframAlpha for a number, and inspecting image alt text to determine whether the number is even. The joke is the absurdly overcomplicated approach to a trivial parity check, making it a reaction to unnecessarily complex code or overengineering.
code editor screenshot / скриншот редактора кодаPython code / код на PythonFirefox browser / браузер FirefoxSelenium / SeleniumWolframAlpha webpage / страница WolframAlphacomputer screen / экран компьютераtext code / текст кодаfunction definition / определение функцииURL / URLdark theme / тёмная тема
- @gentoomemes / 4518 2023-05-13
- Type
- image
- Size
- 539×445 · 28.1 KiB
- Mood
- absurd, sarcastic
- Language
- en
- Added