-
-
Save Tairy/97ed571280f223d61e90 to your computer and use it in GitHub Desktop.
questconsult cal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import requests | |
import re | |
from bs4 import BeautifulSoup | |
import xlwt | |
def getData(temp): | |
wbk = xlwt.Workbook() | |
sheet = wbk.add_sheet('sheet 1') | |
session = requests.Session() | |
headers = { | |
"User-agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36" | |
} | |
# post data | |
# t0:Temperature p0: Pressure | |
# c1:Component id 01 zc1: Mole fraction in mixture | |
# ... | |
body = { | |
"t0":temp, | |
"p0":"1000", | |
"c1":"15", | |
"zc1":"0.2088", | |
"c2":"1", | |
"zc2":"0.1113", | |
"c3":"51", | |
"zc3":"0.0945", | |
"c4":"7", | |
"zc4":"0.0812", | |
"c5":"4", | |
"zc5":"0.0768", | |
"c6":"16", | |
"zc6":"0.06", | |
"c7":"2", | |
"zc7":"0.595", | |
"c8":"14", | |
"zc8":"0.58", | |
"c9":"3", | |
"zc9":"0.0368", | |
"c10":"195", | |
"zc10":"0.0366" | |
} | |
reponse = session.post("http://www.questconsult.com/cgi-bin/other_thermo_properties",data = body, headers = headers) | |
soup = BeautifulSoup(reponse.text) | |
gotData = soup.find_all('pre') | |
line = 0 | |
for i in gotData: | |
for t in i.text.split("\n"): | |
if len(t.split(":")) > 1: | |
sheet.write(line,0,t.split(":")[0]) | |
sheet.write(line,1,t.split(":")[1]) | |
else : | |
sheet.write(line,0,"========") | |
line += 1 | |
wbk.save(temp + '.xls') | |
print "Get " + temp + " Success!" | |
if __name__== "__main__": | |
# just add your temp in this list | |
temps = ['273.15', '274.15', '275.15'] | |
for temp in temps: | |
getData(temp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment