'''
得到导航的域名来生成以www.和m开头的域名
'''
class Shengcheng_domain(object):
'''
读取本地原始域名
'''
def open_url(self):
with open('../ys_domain/ys.txt', 'r', encoding='utf-8') as f:
data = f.readlines()
return data
# 生成以www.开头的域名
def w_url(self, data):
w_list = list()
for da in data:
da = 'www.' + da
print(da)
w_list.append(da)
return w_list
# 生成以m.开头的域名
def m_url(self, data):
m_list = list()
for da in data:
da = 'm.' + da
print(da)
m_list.append(da)
return m_list
# 保存域名
def save(self, mlist, wlist):
for d in data:
with open('../domain_one/jg.txt', 'a+', encoding='utf-8') as f:
f.write(d)
for w in wlist:
with open('../domain_one/jg.txt', 'a+', encoding='utf-8') as f:
f.write(w)
for m in mlist:
with open('../domain_one/jg.txt', 'a+', encoding='utf-8') as f:
f.write(m)
if __name__ == '__main__':
sc = Shengcheng_domain()
data = sc.open_url()
wlist = sc.w_url(data)
mlist = sc.m_url(data)
sc.save(mlist, wlist)
转载于:https://www.cnblogs.com/victorstudy/p/11425868.html