Skip to content

Instantly share code, notes, and snippets.

@wkerzendorf
Created May 15, 2015 12:38
Show Gist options
  • Save wkerzendorf/3bc9b7f86226471e5b60 to your computer and use it in GitHub Desktop.
Save wkerzendorf/3bc9b7f86226471e5b60 to your computer and use it in GitHub Desktop.
Download the photoabsorption cross section
import requests
from bs4 import BeautifulSoup
base_url = 'http://henke.lbl.gov/cgi-bin/pert_cgi.pl'
def get_photo_absorption_cross_section(element_code, energy):
data = requests.get(base_url, data=dict(
Element=element_code, Energy=energy))
bs = BeautifulSoup(data.text)
for item in bs.find_all('li'):
if item.text.startswith('Photo'):
return float(item.text.split(':')[1].strip().replace('cm^2/g', ''))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment