Help with converting names to colors

so I was working on my colors project, and I made a block (based on one I made a long time ago) that reports the name of a color, using colornames.org. then, I tried to create a block that does the opposite, using the search function of colornames.org to try to report a hex of a color using the url [] block. The [exact V] named [] colors :: rgb(0,160,150) :: reporter reporter in the project reports the correct url that needs to be scanned, but when I try to do anything useful with the url, even when using cors proxies, either the reports blank or some infinite loading screen html is reported. note: the block above should report a list of all partial matches if that is the option chosen, or the only exact match if exact is the option chosen. any help to make the above block work is appreciated!

There's a huge list array of every CSS color name and their respective hex codes in my HTML parser but I forgot what sprite it's in. It probably uses a different syntax than what you use, though

With that, you wouldn't have to use a url block, but it would inflate the size of the library by.. a lot

uhh... can you look in the project... there's literally a (css color names :: rgb(0,160,150) block which is working already. I also wanted to use colornames.org since they seem to have the biggest database of named colors I could find - if there's something better pls let me know!

..so why are you using the URL block

because css doesnt have every single color

Oh you want the names of every color? The best way would probably just to scrape it manually somehow

uhh............ I literally said how!

offtopic

borkmaster is back!

I get the full HTML of the website when I use the corsproxy:

Maybe it has something to do with your internet and they might be blocking the proxy. Same thing happens when I do things using corsproxy on my campus wifi

fixed

It's because that's not the api, it's the html search page.

They want to search for colors given a name. The API doesn’t have that. It only has last 100 submissions, lookup given hex code, and a random color. Getting the HTML is the only way.

It's not obvious to me that a database with a gazillion silly color names is desirable, especially if you want to use partial matches. If you want something bigger than the X11 list, look into Pantone. But they're a commercial enterprise selling color samples, so I'm not sure they allow free searching.

my code doesn't search the database, the website does. that's why partial matches will work - the website does that for me. I think the problem I have been having is that the url block is reporting the wrong thing (either null or a loading screen, even after I used multiple cors proxies), rather than myself not being able to search the database with snap code.

glad it works for you, but the cors proxy reports blank on both by home and school wifi.

this cors proxy sucks use a different one like allorigins.win

well any other one I try reports blank. any ideas?

its returning nothing because this.. isn't a valid url??
image

oh!

well, I keep getting this:

long Name Search - colornames.org
  <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarMaster">
    <span aria-hidden="true"></span>
    <span aria-hidden="true"></span>
    <span aria-hidden="true"></span>
  </a>
</div>

<div id="navbarMaster" class="navbar-menu">
  <div class="navbar-start">
    <a class="navbar-item" href="/fresh/">Latest</a>
    <a class="navbar-item" href="/search/">Search</a>
    <a class="navbar-item" href="/download/">Data/API</a>
    <a class="navbar-item" href="/contact/">Contact</a>
  </div>

  <div class="navbar-end">
    <div class="navbar-item"><h6 class="title is-6 has-text-grey-light"><span id="nameCount">Much</span> colors named</h6></div>
    <div class="navbar-item">
      <div class="buttons">
         <a class="button is-dark" href="/random/">
           <span class="icon is-small"><i class="fas fa-random"></i></span>
           <span>Get Lucky</span>
         </a>
      </div>
    </div>
  </div>

</div>
  <h1 class="title is-3">Name Search: &ldquo;&rdquo;</h1>
  <p class="content">Find all colors with a specific name by entering it below...</p>

  <form action="/search/results/">

    <div class="field">
      <div class="control">
        <label class="radio">
          <input type="radio" name="type" value="exact" >
          Exact match
        </label>
        <label class="radio">
          <input type="radio" name="type" value="partial" checked>
          Partial
        </label>
      </div>
    </div>

    <div class="field has-addons">
      <div class="control">
        <input name="query" minlength="3" required class="input" type="text" placeholder="e.g. Bright Blue" value="">
      </div>
      <div class="control">
        <button class="button is-info">
          Search
        </button>
      </div>
    </div>
  </form>

          <br/>
    <article class="message is-warning">
      <div class="message-body">
        No results found for that query.
      </div>
    </article>
      </div>

Website content is licensed CC BY NC SA 4.0.
The downloadable data is CC0 1.0.

edit: it works now, and thanks for the code!

I mean it works, but you have to split by json an extra time.

that's because the cors proxy I used has the contents in a JSON string for whatever reason