1 import requests 2 import re 3 4 url = ‘http://www.ygdy8.net/html/gndy/dyzz/list_23_{}.html‘ 5 for n in range(1, 2): 6 new_url = url.format(n) 7 html_1 = requests.get(new_url) 8 html_1.encoding = ‘gb2312‘ 9 detil_list = re.findall(‘<a href="(.*?)" class="ulink">‘, html_1.text) 10 11 for m in detil_list: 12 b_url = ‘http://www.ygdy8.net‘ + m 13 html_2 = requests.get(b_url) 14 html_2.encoding = ‘gb2312‘ 15 ftp = re.findall(‘<a href="(.*?)">.*?</a></td>‘, html_2.text) 16 with open(‘tddy.txt‘, ‘a‘, encoding=‘utf-8‘) as f: 17 f.write(ftp[0] + ‘\n‘)