Script nist-scraper.py

usage: nist-scraper.py [-h] [-u] formula

Retrieves and prints a table of molecular constants from the NIST Chemistry Web Book [NISTRef]

To do so, it uses web scraping to navigate through several pages and parse the desired information
from the book web pages.

It does not provide a way to list the molecules yet, but will give an error if the molecule is not
found in the NIST web book.

Example:

    print-nist.py OH

**Note** This script was designed to work with **diatomic molecules** and may not work with other
         molecules.

**Warning** The source material online was known to contain mistakes (such as an underscore instead
            of a minus signal to indicate a negative number). We have identified a few of these,
            and build some workarounds. However, we recommend a close look at the information parsed
            before use.

**Disclaimer** This script may stop working if the NIST people update the Chemistry Web Book.

References:

[NISTRef] http://webbook.nist.gov/chemistry/

positional arguments:
  formula        NIST formula

optional arguments:
  -h, --help     show this help message and exit
  -u, --unicode  Unicode output (default is to contain only ASCII characters)
                 (default: False)

This script belongs to package pyfant

Usage examples

Usage examples:

nist-scraper.py TiO

will print

*** titanium oxide ***

State       T_e            omega_e    omega_ex_e    omega_ey_e      B_e    alpha_e    gamma_e       D_e    beta_e      r_e  Trans.        nu_00  A
----------  -----------  ---------  ------------  ------------  -------  ---------  ---------  --------  --------  -------  ---------  --------  ---
D           31920.0        1040                                                                                             D <-> X    31940
e 1Sigma+   a + 26598.1     845.2          4.2                  0.4892     0.0023              4.7e-07             1.695    e <-> d R  24297.5
f 1Delta    (a + 19132)     890                                 0.50221                        6.4e-07             1.67292  f <-> a R  19068.9
c 1Phi      a + 17890.2     909.6          4.19                 0.523      0.00313             3.9e-07             1.6393   c <-> a R  17840.6
C 3Delta_r  19617.0         838.26         4.76         0.047   0.48989    0.00306   -3e-05    6.7e-07             1.69383  C <-> X R  19334
B 3Pi_r     16331.3         875            5                    0.50617                        6.86e-07            1.66636  B <-> X R  16066.7
b 1Pi       a+11322.0_3     911.2          3.72                 0.51337    0.00291             6.1e-07             1.65464  b <-> d R   9054.02
A 3Phi_r    14431.0         867.78         3.942                0.50739    0.00315   -1e-05    6.92e-07     2e-09  1.66436  A <-> X R  14163
E 3Pi       12025.0         924.2          5.1                                                                              E <-> X    11871
d 1Sigma+   a + 2215.6     1014.6          4.64                 0.54922    0.00337             6e-07               1.59972
a 1Delta    a              1009.3          3.93                 0.5376     0.00298             5.9e-07             1.61692
X 3Delta_r  197.5          1009.02         4.498       -0.0107  0.53541    0.00301   -1.1e-05  6.03e-07     3e-09  1.62022
nist-scraper.py OH -u

will print the same output with unicode characters:

*** titanium oxide ***

State       T_e            omega_e    omega_ex_e    omega_ey_e      B_e    alpha_e    gamma_e       D_e    beta_e      r_e  Trans.       nu_00  A
----------  -----------  ---------  ------------  ------------  -------  ---------  ---------  --------  --------  -------  --------  --------  ---
D           31920.0        1040                                                                                             D ↔ X     31940
e ⁱSigma⁺   a + 26598.1     845.2          4.2                  0.4892     0.0023              4.7e-07             1.695    e ↔ d R   24297.5
f ⁱDelta    (a + 19132)     890                                 0.50221                        6.4e-07             1.67292  f ↔ a R   19068.9
c ⁱPhi      a + 17890.2     909.6          4.19                 0.523      0.00313             3.9e-07             1.6393   c ↔ a R   17840.6
C ³Delta_r  19617.0         838.26         4.76         0.047   0.48989    0.00306   -3e-05    6.7e-07             1.69383  C ↔ X R   19334
B ³Pi_r     16331.3         875            5                    0.50617                        6.86e-07            1.66636  B ↔ X R   16066.7
b ⁱPi       a+11322.0_3     911.2          3.72                 0.51337    0.00291             6.1e-07             1.65464  b ↔ d R    9054.02
A ³Phi_r    14431.0         867.78         3.942                0.50739    0.00315   -1e-05    6.92e-07     2e-09  1.66436  A ↔ X R   14163
E ³Pi       12025.0         924.2          5.1                                                                              E ↔ X     11871
d ⁱSigma⁺   a + 2215.6     1014.6          4.64                 0.54922    0.00337             6e-07               1.59972
a ⁱDelta    a              1009.3          3.93                 0.5376     0.00298             5.9e-07             1.61692
X ³Delta_r  197.5          1009.02         4.498       -0.0107  0.53541    0.00301   -1.1e-05  6.03e-07     3e-09  1.62022