[Python]爬虫学习爬某个表情站

直接上代码:

import requests
import  re
def get_urls():
    response=requests.get('http://qq.yh31.com/zjbq/2920180.html','utf-8')
    url_addr=r'<img border="0".*? src="(.*?)"'
    url_list=re.findall(url_addr,response.text)
    return url_list
def get_gif(url,name):
    response=requests.get(url,'utf-8')
    with open(r'C:\Users\Administrator\Desktop\DATA\%d.gif' %name,'wb') as ff:
      ff.write(response.content)
if __name__=='__main__':
   url_list= get_urls()
   a=101
   for url in url_list:
       com_url='http://qq.yh31.com'+url
       get_gif(com_url,a)
       a+=1
分享到:

评论已关闭。