Home > Blockchain >  Python XML API request on Linux cmd returns output with request's detail. Is there a way to hid
Python XML API request on Linux cmd returns output with request's detail. Is there a way to hid

Time:03-19

Here is the example :

query_state = "curl -k --location -g --request GET 'https://hostname/api/?type=op&cmd=<show><state></state></show>&key=API-KEY'"
get_state = os.popen(query_state).read()

soup = BeautifulSoup(get_state, 'lxml')
state = soup.find('state').string
print(state)

Here is output:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4538  100  4538    0     0  27840      0 --:--:-- --:--:-- --:--:-- 27840

active

I need only 'active' which is fine, but to reject request view?

I tried with:

get_state = os.system(query_state)

but output cannot be assigned to a variable.

CodePudding user response:

You can hide the verbose output with the curl --silent flag.

https://curl.se/docs/manpage.html

  • Related