DEV Community

Wolf
Wolf

Posted on

Is there an api/library in python for ray.so or carbon.now.sh?

I have been looking for an API and/or library for websites like (https://ray.so/) and (https://carbon.now.sh/) 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 (2)

Collapse
 
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 = 'https://ray.so/'
r = session.get(url, params=params)
print(r.url)
html: HTML = r.html
html.render()
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
Wolf
Traceback (most recent call last):
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\subprocess.py", 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\test.py", line 6, in <module>
    driver = webdriver.Chrome()
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", 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\webdriver.py", line 90, in __init__
    self.service.start()
  File "C:\Users\wolf\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
Enter fullscreen mode Exit fullscreen mode