This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

   1 import urllib2
   2 from BeautifulSoup import BeautifulSoup
   3 
   4 class Element:
   5     "A simple container of arbitrary named attributes."
   6     def __init__(self, **kw):
   7         self.__dict__.update(kw)
   8     def __repr__(self):
   9         return str(self.__dict__)
  10 
  11 def FetchElements():
  12     """Chemical Elements
  13 
  14       Retrieves a list of the basic chemical elements, along with a few of
  15       their associated properties.
  16     """
  17 
  18     opener = urllib2.build_opener()
  19     opener.addheaders = [('User-agent', 'Mozilla/5.0')]
  20 
  21     page = opener.open("http://en.wikipedia.org/wiki/List_of_elements_by_atomic_number")
  22     soup = BeautifulSoup(page)
  23     page.close()