1 import requests
2 import os
3 import urllib
4 import urllib.request
5 from bs4 import BeautifulSoup
6
7 path = '/users/hi/desktop/' #已有文件夹路径
8 title = 'luhan' #新文件夹名称
9 new_path = os.path.join(path,title)
10 if not os.path.isdir(new_path):
11 os.makedirs(new_path)
12
13 url = "http://lusparkle0420.lofter.com/"
14 r = requests.get(url)
15 soup = BeautifulSoup(r.text,'lxml')
16
17
18 n = 0
19 for link in soup.find_all('a'):
20 n = n+1
21 print(link.get('href'))
22 # urllib.request.urlretrieve(link,) #存储
23 print("---------------------------------")
24 print('链接总计:',n)
存储未完成