本帖最后由 mikeee 于 2020-1-28 22:34 编辑
[Python] 纯文本查看 复制代码
r'''
gen te mp3 download list
2020
curl -I http://audiocdn.economist.com/sites/default/files/AudioArchive/2020/20200104/Issue_9175_20200104_The_Economist_Full_edition.zip # OK
2018
9073 20180106
...
9124 20181229
2019
9124 20190105
20191221 9174
'''
from datetime import datetime, timedelta
# 2018
# def gen_dl_addr(issue_no=9073, starting_issue=9073, base_date='20180106'):
# 2019
# def gen_dl_addr(issue_no=9124, starting_issue=9124, base_date='20190105'):
# 2020
def gen_dl_addr(
issue_no: int = 9175,
starting_issue: int = 9175,
base_date: str = '20200104',
)-> str:
''' gen_dl_addr '''
if issue_no < starting_issue:
issue_no = starting_issue
base_date_ = datetime.strptime(base_date, '%Y%m%d')
day_diff = issue_no - starting_issue
curr_date = base_date_ + timedelta(day_diff * 7)
date_str = datetime.strftime(curr_date, '%Y%m%d')
year_str = datetime.strftime(curr_date, '%Y')
dl_str = f'http://audiocdn.economist.com/sites/default/files/AudioArchive/{year_str}/{date_str}/Issue_{issue_no}_{date_str}_The_Economist_Full_edition.zip'
return ' '.join([date_str, str(issue_no), dl_str]) + '\n'
def main():
''' main '''
starting_issue = 9124
base_date = '20190105'
starting_issue = 9175
base_date = '20200104'
# 2021
# starting_issue = 9226
# base_date='20210102'
file_name = f'{base_date[:4]}-mp3-dl-addr.txt'
file_name = f'{base_date[:4]}-te-mp3-dl-addr.txt'
with open(file_name, 'wt', encoding='utf-8') as fha:
for elm in range(starting_issue, starting_issue + 51):
fha.write(
gen_dl_addr(
issue_no=elm,
starting_issue=starting_issue,
base_date=base_date))
if __name__ == '__main__':
main()
知名时政杂志《雪人》考研必攻。如能无障碍听懂音频的85%,考研英语科就大致问题不大了。可能需架梯子才能下载。改变 starting_issue /base_date (例如 2021年:starting_issue = 9226; base_date = '20210102')即可计算全年的音频链接。音频一般中国时间周五早上可下。觉得有用就评个分回个帖什么的。
|