DEV Community


Posted on

Is there an api/library in python for or

I have been looking for an API and/or library for websites like ( and ( my goals for using this API / library is to interact with the website and download the image that is outputted I found a few so far but they don't work: carbon-now-sh-API-Wrapper(this one wasn't working) and carbonsh(this one wasn't saving the file).
My goal is to get something similar to this: carbonara but for python.

Top comments (5)

wolfpack9108 profile image
Wolf • Edited
from requests_html import HTMLSession, HTML
import base64

session = HTMLSession()
code = b'x = "hello world"\nprint(x)'
code = base64.b64encode(code)

params = {
    'colors': 'midnight',
    'background': 'true',
    'darkMode': 'true',
    'padding': '16',
    'title': 'hello',
    'code': code,
    'language': 'python',
url = ''
r = session.get(url, params=params)
html: HTML = r.html
Enter fullscreen mode Exit fullscreen mode

made this but only makes a link not the image I need to get the image from the link generated in this code.

wolfpack9108 profile image
Traceback (most recent call last):
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\wolf\Partnership project\", line 6, in <module>
    driver = webdriver.Chrome()
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chromium\", line 90, in __init__
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see
Enter fullscreen mode Exit fullscreen mode