0

I have a JSON output from an API written in python I am fetching the results in JSON but I want to append a string let say abc.com to each result.

  {
  "subdomains": [
    "results",
    "www",
    "sip",
    "cdn",
    "pavpn",
    "intranet",
    "laxvpn",
    "news",
    "files",
  ],
}

So each returned value should be parsed out and appended like results.abc.com pavpn.abc.com etc so I can get a clean string out of it containing only subdomain plus abc.com appended to that.

I have tried many solutions:

`result = map(lambda x: str(x) + "." + str(domain_name), response.text)`

I want the output to be

subdomain.abc.com
subdomain.abc.com

etc.. Any help will be appreciated.

Thanks

1 Answer 1

1

like this?

>>> d = {
  "subdomains": [
    "results",
    "www",
    "sip",
    "cdn",
    "pavpn",
    "intranet",
    "laxvpn",
    "news",
    "files",
  ],
}

>>> [x + "." + domain for x in d["subdomains"]]
# result ['results.abc.com', 'www.abc.com', 'sip.abc.com', 'cdn.abc.com', 'pavpn.abc.com', 'intranet.abc.com', 'laxvpn.abc.com', 'news.abc.com', 'files.abc.com']
Sign up to request clarification or add additional context in comments.

2 Comments

yes great! But on the top of that i want plain text output like subdomain.abc.com\n(newline) subdomain.abc.com
Use simple Python .join Which will be: "\n".join([x + "." + domain for x in d["subdomains"]])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.