coding cp1251 tagBeginFile xml version encoding UTF-8 DownloadList Ver

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#-*- coding:cp1251 -*-
tagBeginFile = '<?xml version="1.0" encoding="UTF-8"?>\n<DownloadList Version="4" NextID="4">'
tagBeginBlock = '\n<DownloadFile>\n <ID>'
tagURL = '</ID>\n <URL>http://'
FirstPart = raw_input('Input first part of URL: ')
# ввод изменяющейся части ссылки
numBegin = input('Input first number: ')
numEnd = input('Input last number: ')
LastPart = raw_input('Input last part of URL: ')
tagEndBlock = '</URL>\n <FileName></FileName>\n <State>0</State>\n <Size>0</Size>\n <SaveDir>C:\Downloads\</SaveDir>\n <Date>01/31/2009 21:00:47</Date>\n</DownloadFile>'
tagEndFile = '\n</DownloadList>'
f = open('list.xml','a')
f.write(tagBeginFile)
kolvo = numEnd - numBegin # количество файлов
for x in range(kolvo):
f.write(tagBeginBlock)
f.write(str(x+1)) # ID
f.write(tagURL)
f.write(FirstPart + str(numBegin+x) + LastPart) # URL
f.write(tagEndBlock)
f.write(tagEndFile)
raw_input()