NIST Web bookからのデータ取得
NISTのWeb bookには、 以下のようにShomate式により気相の比熱、Enthalpy, Entropy計算に必要な係数が記載されています。

温度範囲毎に係数が分かれているため、上記のテーブルをまとめてスクレイピングし、csvファイルに落とすコードを作成していきます。
テーブルの抽出
NIST webbookで例えばCOの気相物性を調べると、そのURLは以下のようになっている。
Carbon monoxide
This page, "Carbon monoxide", is part of the NIST Chemistry WebBook. This site and its contents are part of the NIST Sta...
xxx.cgiまでがベースのURL、そこにCAS番号やMaskといったパラメーターが必要となる。
以下の例ではGoogle Colaboratory上でスクレイピングし、結果をcsvで出力している。
import os
import re
import csv
import requests
from bs4 import BeautifulSoup
params = {'ID': 'C630080' , 'Units': 'SI' , 'Mask' : '1' }
response = requests.get('http://webbook.nist.gov/cgi/cbook.cgi', params=params)
soup = BeautifulSoup(response.text)
#h3タグを取得(Gas Phase Heat Capacity (Shomate Equation))
h3 = soup.h3
#最初のpタグ
p1 = soup.find_all('td', class_='exp right-nowrap')
writer = csv.writer(file)
for row in rows:
csvRow = []
for cell in row.findAll(['td', 'th']):
csvRow.append(cell.get_text())
writer.writerow(csvRow)
files.download('data.csv')

コメント