Strip HTML tags in python

Posted by in Software, Tutorial

Note: This is a post transferred from Laurii for historical and consolidation purposes. A common problem I have to deal with quite often is to remove all HTML tags from a document. While this is easy for XML (well formatted etc.) and you could do it by hand with a regexp, HTML has a bit more problems. There are several solutions to get around this… Using a browser This is a bit overkill, but you could use a browser’s renderer to “display” the string content and then get it as…read more

Brand Colors

Posted by in Software

A while ago I’ve found a list of common brands’ colors. A little experiment: If you find this post and ad below useful, please check the ad out :-)

Copy Text to Clipboard in HTML Page using JavaScript

Posted by in Software

I’ve got a problem on one of my sites: I have a unique identifier displayed on one page, which I need to make it easy to copy to clipboard. After looking online, I’ve found three approaches using only JS. Clipboard.js Clipboard.js is a new (September 2015) approach which uses only JS to copy the text transparently (using the Selection/execCommand APIs). The code is as simple as:

where trigger is a CSS selector. [Thanks Gabriel Gularte]. Popup approach This method opens a dialog box with a text. The code is…read more

Send POST to server via python-requests

Posted by in Software

The other day I’ve had a question asked: How do you send a form data to a server and get the reply? My solution involves python-requests:

r.text contains the reply HTML page, which then needs to be processed via e.g. python’s DOM processing module or BeautifulSoup (if you’re looking for something more tolerant). HTH, A little experiment: If you find this post and ad below useful, please check the ad out :-)

Decent image loader widget in django

Posted by in Software

I’m working on a website where I need to be able to load an image. The default widget is abysmal; it has a url to the current image, a checkbox and a file loader input element. Even styled, it looks pretty bad. So, I’ve taken upon myself to prettify it and get from this: to this: To accomplish the transformation, we need: Crispy forms – just because my app uses it and it gives nice bootstrap-based formatting Floppy forms – because it allow us to customise widgets markusslima’s bootstrap-filestyle –…read more