Commit f940b27b authored by Fabian P. Schmidt's avatar Fabian P. Schmidt

Fix fetch_tle_from_celestrak to accept plaintext responses

Apparently Celestrak satcat/tle.php endpoint changed the response
format from html to plaintext. This change simplifies the parser
on our side and allows us to drop the lxml dependency.

Fixes #11 (fetch_tle_from_celetrak throws IndexError).
parent 28bb3ed3
......@@ -3,7 +3,6 @@ import requests
import pkg_resources
import logging
from lxml import html
from sgp4.earth_gravity import wgs72
from import twoline2rv
......@@ -54,12 +53,11 @@ def fetch_tle_from_celestrak(norad_cat_id, verify=True):
page = html.fromstring(r.text)
tle = page.xpath('//pre/text()')[0].split('\n')
if tle[1].strip() == 'No TLE found':
if r.text == 'No TLE found':
raise LookupError
tle = r.text.split('\r\n')
return tle[1].strip(), tle[2].strip(), tle[3].strip()
......@@ -10,7 +10,6 @@ setup(name='satellitetle',
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment