Python Forum
Getting Unique values from LISTS
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting Unique values from LISTS
#3
import urllib3
from bs4 import BeautifulSoup 
import requests

server_name="https:***********************************************"

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning


http = urllib3.PoolManager()
headers = urllib3.util.make_headers(basic_auth='****:****')
r = http.request('GET', server_name, headers=headers)
soup = BeautifulSoup(r.data, 'lxml')
Server=[i.get_text() for i in soup.find_all('ops:name')]
Identifier=[ i['identifier'] for i in soup.find_all('ops:resource') ]
Convert_Dict_01 = dict(zip(Server,Identifier))
#print(Convert_Dict_01)
for i in Identifier:
        Properties_URL="https:/*********/"+i+"/properties"
        r = http.request('GET', Properties_URL, headers=headers)
        soup=BeautifulSoup(r.data, 'lxml')
        Property_ID=[j['resourceid'] for j in soup.find_all('ops:resource-property') ]
        for element in soup.find_all("ops:property"):
            Name=element['name']
            Total=[element.get_text()]
            if 'scsi' in Name:
                Convert_Dict_02 = dict(zip(Property_ID,Total))
                for i,j in Convert_Dict_01.items():
                    for m,n in Convert_Dict_02.items():
                        if (Convert_Dict_01[i] == m):
                            SERVER = [i]
                FINAL=[SERVER,Total]
                print(FINAL)
Output:
Thanks for your reply metulburr, since my output coming in multiple list , i would like to know how i can get all list under one list? Since my output gives tons of data, i cannot copy the entire output and put it in one list , please suggest me to get multiple list under one list FINAL=[['scext', '80.0'],['scext', 'COLFUJDX440_DS11'],['scext', 'Hard disk 1'],['scext', '100.0'],['scext', 'COLFUJDX440_DS11'],['scext', 'Hard disk 2'],['scext', '200.0'],['scext', 'COLFUJDX440_DS11'],['scext', 'Hard disk 3'],['SCEXTVMD', '100.0'],['SCEXTVMD', 'COLHG600P01_DS33'],['SCEXTVMD', 'Hard disk 1'],['SCEXTVMD', '40.0'],['SCEXTVMD', 'COLHG600P01_DS33'],['SCEXTVMD', 'Hard disk 2'],['SCEXTVM', '100.0'],['SCEXTVMD', 'COLHG600P01_DS33'],['SCEXTVMD', 'Hard disk 3'] ]
Reply


Messages In This Thread
Getting Unique values from LISTS - by aankrose - Oct-16-2019, 08:37 PM
RE: Getting Unique values from LISTS - by metulburr - Oct-16-2019, 09:28 PM
RE: Getting Unique values from LISTS - by aankrose - Oct-17-2019, 05:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Using Lists as Dictionary Values bfallert 8 356 Apr-21-2024, 06:55 AM
Last Post: Pedroski55
  Get an average of the unique values of a column with group by condition and assign it klllmmm 0 290 Feb-17-2024, 05:53 PM
Last Post: klllmmm
  user input values into list of lists tauros73 3 1,079 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,387 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  5 variants to invert dictionaries with non-unique values Drakax1 2 2,623 Aug-31-2020, 11:40 AM
Last Post: snippsat
  Inserting values from multiple lists sqlite azulu 1 2,513 May-24-2020, 08:40 AM
Last Post: ibreeden
  Finding Max and Min Values Associated with Unique Identifiers in Python ubk046 1 2,068 May-08-2020, 12:04 PM
Last Post: anbu23
  How to compare two columns and highlight the unique values of column two using pandas shubhamjainj 0 4,302 Feb-24-2020, 06:19 AM
Last Post: shubhamjainj
  Why does this list of lists end up with the same values alehak 2 2,613 Jul-18-2019, 12:34 PM
Last Post: perfringo
  Generate unique random numbers from different lists Takeshio 5 3,803 May-24-2019, 07:29 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020