I have a json values that I need stripped of all html tags.
After using the following function:
def payloaded():
from urllib.request import urlopen
with urlopen("www.example.com/payload.json") as r:
data = json.loads(r.read().decode(r.headers.get_content_charset("utf-8")))
text = (data["body"]["und"][0]["value"])
return(text)
This is the returned (text):
<div class="blah">'<p>This is the text.</p>\r\n'
This is the original (text):
<div class="blah"><p>This is the text.</p>
Note: I need all html tags stripped, and there is no real guidelines of what the tags I will be getting.
This is what I want the (text) to be:
This is the text.
This is the post function I am using:
def add_node_basic(text)
url = "www.example.com"
headers = {"content-type": "application/json"}
payload = {
"auth_token": x,
"docs":
{
"id": y,
"fields": [
{"name": "body", "value": text, "type": "text"},
]}
}
r = requests.post(url, data=json.dumps(payload), headers=headers)
Any suggestions on how to achieve this is much appreciated!
This is the text.
...`