Skip to content

Tag: python

How to scrape Trusted Shops?

I would appreciate your help on this scraping problem. I would like to scrape this site: https://www.trustedshops.de/bewertung/info_XDAD39B874C275A0751198C2510C3C670.html Although my code does not give me an error message, I do not see any output. I believe the problem is the bs.find_all statement; basically,…

Find and replace XML content in MS Word Document.xml with Python

I’m following the below guide to search a replace a keyword in the DOCX document.xml https://virantha.com/2013/08/16/reading-and-writing-microsoft-word-docx-files-with-python/ I’m trying to find ‘abc’ within the w:instrText tag and replace it with ‘zzzz’ Please find my code…

Create a customer converter and validator using ATTRS

I am trying to learn attrs and I have two questions. Please note that I am using the ATTRS library, not ATTR. How do I create a converter to change typ to uppercase? —> I solved this question. The formula below is updated. :) How do I create a validator to ensure that typ is contained within a list? …

How to search via Enums Django

I’m trying to a write a search function for table reserving from a restaurant, I have a restaurant model: which has a enum for kitchen_type: And this is the search function in view.py: So how am I able to search for kitchen_type in the view? Answer Instead of using a list of tuples I would recommend ext…

np.diag not including 0s in the array

I have an expression that yields the following result: I want to make a diagonal 2X2 matrix which has 0.5 and 0 on its diagonal. But when I use the following code: A being the above array, I get the following result: Why does python not include the second element from A on the array and how can I include