Skip to content

Instantly share code, notes, and snippets.

@rmax
Last active May 29, 2016 20:17
Show Gist options
  • Save rmax/035963e43f22a7a3ccb9ae4aab39a38a to your computer and use it in GitHub Desktop.
Save rmax/035963e43f22a7a3ccb9ae4aab39a38a to your computer and use it in GitHub Desktop.
$ scrapy shell "http://ssd.jpl.nasa.gov/?planet_phys_par"
...
In [1]: data = []
In [2]: for row in response.xpath('//table[count(./tr) > 3 and count(./tr[1]/td) > 3]/tr'):
data.append([' '.join(filter(None, map(unicode.strip, td.css('::text').extract()))) for td in row.xpath('td')])
...:
In [3]: pd.DataFrame(data)
0 1 2 3 \
0 Planet Equatorial Radius Mean Radius Mass
1 (km) (km) (x 10 24 kg)
2 Mercury 2439.7 ±1.0 [ D ] 2439.7 ±1.0 [ D ] 0.330104 ±.000036 [ F ]
3 Venus 6051.8 ±1.0 [ D ] 6051.8 ±1.0 [ D ] 4.86732 ±.00049 [ G ]
4 Earth 6378.14 ±.01 [ D ] 6371.00 ±.01 [ D ] 5.97219 ±.00060 [ H ]
5 Mars 3396.19 ±.1 [ D ] 3389.50 ±.2 [ D ] 0.641693 ±.000064 [ I ]
6 Jupiter 71492 ±4 [ D ] 69911 ±6 [ D ] 1898.13 ±.19 [ J ]
7 Saturn 60268 ±4 [ D ] 58232 ±6 [ D ] 568.319 ±.057 [ K ]
8 Uranus 25559 ±4 [ D ] 25362 ±7 [ D ] 86.8103 ±.0087 [ L ]
9 Neptune 24764 ±15 [ D ] 24622 ±19 [ D ] 102.410 ±.010 [ M ]
10 Pluto 1151 ±6 [ C ] 1151 ±6 [ C ] .01309 ±.00018 [ N ]
4 5 6 \
0 Bulk Density Sidereal Rotation Period Sidereal Orbit Period
1 (g cm -3 ) (d) (y)
2 5.427 ±.007 [ * ] 58.6462 [ D ] 0.2408467 [ B ]
3 5.243 ±.003 [ * ] -243.018 [ D ] 0.61519726 [ B ]
4 5.5134 ±.0006 [ * ] 0.99726968 [ B ] 1.0000174 [ B ]
5 3.9340 ±.0008 [ * ] 1.02595676 [ D ] 1.8808476 [ B ]
6 1.3262 ±.0004 [ * ] 0.41354 [ D ] 11.862615 [ B ]
7 0.6871 ±.0002 [ * ] 0.44401 [ D ] 29.447498 [ B ]
8 1.270 ±.001 [ * ] -0.71833 [ D ] 84.016846 [ B ]
9 1.638 ±.004 [ * ] 0.67125 [ D ] 164.79132 [ B ]
10 2.05 ±.04 [ * ] -6.3872 [ D ] 247.92065 [ B ]
7 8 9 10
0 V(1,0) Geometric Albedo Equatorial Gravity Escape Velocity
1 (mag) (m s -2 ) (km s -1 )
2 -0.60 ±0.10 [ E ] 0.106 [ B ] 3.70 [ * ] 4.25 [ * ]
3 -4.47 ±0.07 [ E ] 0.65 [ B ] 8.87 [ * ] 10.36 [ * ]
4 -3.86 [ B ] 0.367 [ B ] 9.80 [ * ] 11.19 [ * ]
5 -1.52 [ B ] 0.150 [ B ] 3.71 [ * ] 5.03 [ * ]
6 -9.40 [ B ] 0.52 [ B ] 24.79 [ * ] 60.20 [ * ]
7 -8.88 [ B ] 0.47 [ B ] 10.44 [ * ] 36.09 [ * ]
8 -7.19 [ B ] 0.51 [ B ] 8.87 [ * ] 21.38 [ * ]
9 -6.87 [ B ] 0.41 [ B ] 11.15 [ * ] 23.56 [ * ]
10 -1.0 [ B ] 0.3 [ B ] 0.66 [ * ] 1.23 [ * ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment