2021-10-25 20:36 GMT+02:00, Sagar Acharya <sagaracharya_AT_tutanota.com>:
> Hello,
>
> I'm making this software called kamitkami. It's a python script which takes
> 2 inputs foo.html and bar.css and outputs a css file named bar_foo.css which
> contains only the css which applies to the particular html page . This will
> make css extremely minimal and page loading faster.
>
> This code is incomplete yet and I need someone help from surf developers. I
> have the css selectors in a python list, corresponding blocks in another
> list. I also have the html as a string. I think surf must detect whether a
> particular css selector applies to an html string or not. If someone can
> help me on how to do it (what code applies?), or contribute to kamitkami on
> the link below, I'd be grateful.
>
> I'm thinking along the lines of submitting list and html as input to some
> subpart of compiled surf code with os module of python and getting back a
> list of only css selector which applies.
> Thanking you
> Sagar Acharya
This is not suckless, this is webshit.
Any browser with js can do that, I was thinking of a solution but on
stackoverflow is already provided, it seems [0].
To automate the part where you feed your pieces to a browser, you can
contribute a patch for running surf in headless mode.
You're developing in python already so for the time being can probably
succeed with Splash[1] or kicking raw strings to playwright.
[0]
https://stackoverflow.com/a/22638396
[1]
https://github.com/scrapinghub/splash
Received on Tue Oct 26 2021 - 09:50:10 CEST