-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhdnew.py
More file actions
27 lines (24 loc) · 1003 Bytes
/
Copy pathhdnew.py
File metadata and controls
27 lines (24 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from bs4 import BeautifulSoup
download_url = []
def download_file(url):
local_filename = 'love/'
# NOTE the stream=True parameter
r = requests.get(url, stream=True)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush() #commented by recommendation from J.F.Sebastian
return local_filename
for x in xrange(31,40):
response = requests.get('http://www.hdwallpapernew.in/romantic-couple/?galleryPage=%s'% x)
soup = BeautifulSoup(response.text, 'html.parser')
for link in soup.find_all('dt', {'class': 'gallery-icon'}):
#print link.contents
thumburl = link.find('img')['src']
# print thumburl
full_imgurl = thumburl.replace('-270x170', '')
print full_imgurl
print 'Download Started :' + full_imgurl
download_file(full_imgurl)
print 'Download Completed : '