Using the links in Erik's answer and comments, I threw this together.
#!/usr/bin/python3
"""
(C) 2014 Dotan Cohen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3.
http://www.gnu.org/licenses/gpl-3.0.html
"""
import re
import time
import urllib.request
from bs4 import BeautifulSoup
def main():
year_links = []
year_launches = []
total_mass = 0
start_url = 'http://space.skyrocket.de/directories/chronology.htm'
year_links = get_year_links(start_url)
for link in year_links:
launches = get_year_launches(link)
for launch_url in launches:
year_launches.append( launch_url )
for launch in year_launches:
time.sleep(0.1) # Be nice to server
total_mass += get_launch_mass(launch)
print("Total mass: %i KG" % (total_mass, ))
return True
def get_year_links(start_url):
year_links = []
html = urllib.request.urlopen(start_url).read()
parsed_page = BeautifulSoup(html)
links = parsed_page.find_all('a')
for link in links:
link = str(link)
if 'doc_chr' in link:
tmp_link = link[link.find('"')+1:]
tmp_link = tmp_link[:tmp_link.find('"')]
year_links.append(tmp_link)
return year_links
def get_year_launches(year_link):
year_launches = []
url = 'http://space.skyrocket.de/' + year_link[3:]
html = urllib.request.urlopen(url).read()
parsed_page = BeautifulSoup(html)
links = parsed_page.find_all('a')
for link in links:
link = str(link)
if 'doc_sdat' in link:
tmp_link = link[link.find('"')+1:]
tmp_link = tmp_link[:tmp_link.find('"')]
year_launches.append(tmp_link)
return year_launches
def get_launch_mass(launch_url):
mass = 0
try:
url = 'http://space.skyrocket.de/' + launch_url[3:]
html = urllib.request.urlopen(url).read()
parsed_page = BeautifulSoup(html)
for pre_mass_element in parsed_page.find_all(text='Mass:'):
mass_element = pre_mass_element.find_next()
mass = int(re.search(r'(\d+)', mass_element.text).group(0))
except Exception:
pass
return mass
if __name__ == '__main__':
main()
The code took 54 minutes to run, here is the output:
Total mass: 10500435 KG
The code visits a website that lists launches by year, and from each year's page it visits each launch's dedicated webpage. From there the code finds the "Mass" table cell. It then extracts the text of the next cell, pulls out the first integer, and adds that to the running total mass. Python!
Since the answer is in code, it can be periodically rerun as new launches occur and as details of old launches are revised.
Update 25 December, 2017:
Total mass: 13367669 KG
Update 23 December, 2019:
$ time ./mass.py
Total mass: 14466896 KG
real 199m30.311s
user 26m51.576s
sys 0m38.556s
Update 15 February, 2022:
Total mass: 14933443 KG