# -*- coding: utf-8 -*-
import requests
import re
url='https://www.pearvideo.com/category_1'

def getList(url):
    response=requests.get(url)
    videoId=re.findall('<a href="(.*?)" class="vervideo-lilink actplay">',response.text)
    for i in videoId:
        getMp4('https://www.pearvideo.com/'+i)
    
def getMp4(url):
    res=requests.get(url)
    title=re.findall('<title>(.*?)</title>',res.text)
    video=re.findall('srcUrl="(.*?)",',res.text)
    res=requests.get(video[0])
    with open('video/{}.mp4'.format(title[0]),'wb') as f:
        f.write(res.content)
        print('{} downed'.format(title[0]))

getList(url)