爬虫练习:爬取电影天堂下载链接


import requests

import regex

for m in range(31):

    url ='https://www.dy2018.com/html/gndy/dyzz/index_'+str(m)+'.html'

    html = requests.get(url)

    html.encoding ='gb2312' #设定网页编码类型

    data = regex.findall('.*?',html2.text)

        # print(ftp)

        #写入文件

        with open(r'C:\Users\Administrator\Desktop\dy\dytt.txt', 'a',encoding='gb2312') as f:

            f.write(ftp[0]+'\n')

你可能感兴趣的:(爬虫练习:爬取电影天堂下载链接)