from imgUrls import *
from bs4 import BeautifulSoup
import requests
import re

def __main__():
    keyword, links = crawlPage()
    for url in links:
        html = requests.get(url).text
        soup = BeautifulSoup(html, 'lxml')
        links = soup.find_all('img', {'class': 'img-responsive'})
        img_urls = []

        for i in links:
            img_urls.append(i['src'])

        for n in img_urls:
            name = n.split('/')[-2]
            with open('C:/Users/xiaofeng.li/Google Drive/Saved Pictures/%s.jpg' %(keyword+name), 'wb') as f:
                f.write(requests.get(n).content)
            print('%s done.'%(keyword+name))
    print("All done.")

if __name__ == '__main__':
    __main__()