代码拉取完成,页面将自动刷新
import requests
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 \
(KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36'}
'''def get_proxy():
return requests.get("http://127.0.0.1:5010/get/").json()
def delete_proxy(proxy):
requests.get("http://127.0.0.1:5010/delete/?proxy={}".format(proxy))'''
#proxy = get_proxy().get("proxy")
temp = requests.get('http://www.celestrak.com/NORAD/elements/amateur.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle = open('allTLE.txt', 'w')
allTle.write(str(temp.text))
temp = requests.get('http://www.celestrak.com/NORAD/elements/cubesat.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle.write(str(temp.text))
temp = requests.get('http://www.celestrak.com/NORAD/elements/dmc.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle.write(str(temp.text))
temp = requests.get('http://www.celestrak.com/NORAD/elements/weather.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle.write(str(temp.text))
temp = requests.get('http://www.celestrak.com/NORAD/elements/tle-new.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle.write(str(temp.text))
temp = requests.get('http://www.celestrak.com/NORAD/elements/noaa.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle.write(str(temp.text))
temp = requests.get('http://www.celestrak.com/NORAD/elements/other.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle.write(str(temp.text))
temp = requests.get('http://www.celestrak.com/NORAD/elements/other-comm.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle.write(str(temp.text))
temp = requests.get('http://www.celestrak.com/NORAD/elements/stations.txt', headers=headers) #, proxies={"http": "http://{}".format(proxy)})
allTle.write(str(temp.text))
allTle = open('allTLE.txt', 'r')
Tles = str(allTle.read())
allTle.close()
if '<' in Tles:
print('get tles error.')
sys.exit(1)
Tle = open('AutoTLE.txt', 'w')
Tles = Tles.splitlines()
Tles = [i for i in Tles if i != '']
satelistNumber = [
'25544U', '27607U', '43017U', '43137U', '43678U', '44909U', '22825U', '40903U', '40911U', '40907U'
, '40910U', '07530U', '42761U', '42759U', '40908U', '24278U', '42017U', '44354U', '44881U',
'48274U', '43803U', '47438U', '43937U', '25338U', '28654U', '33591U', '44387U', '50466U'
]
satelistName = [
'ISS', 'SO-50', 'AO-91(FOX-1B)', 'AO-92(FOX-1D)', 'PO-101(DIWATA-2B)', 'RS-44', 'AO-27', 'XW-2A', 'XW-2B', 'XW-2D',
'XW-2F', 'AO-7', 'CAS-4A', 'CAS-4B', 'CAS-3H(LilacSat-2)', 'FO-29', 'EO-88', 'PSAT-2(NO-104)', 'CAS-6',
'TIANHE-1', 'JO-97', 'UVSQ-SAT', 'FO-99', 'NOAA-15', 'NOAA-18', 'NOAA-19', 'METEOR-M2', 'XW-3(HO-113)'
]
for i in range(len(satelistNumber)):
temp = [temp for temp in Tles if satelistNumber[i] in temp]
print(satelistName[i])
getTles = satelistName[i] + '\n' + Tles[Tles.index(temp[0])] + '\n' + Tles[Tles.index(temp[0]) + 1] + '\n'
Tle.write(getTles)
Tle.close()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。