Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. # bzf
  2.  
  3. import requests
  4. from bs4 import BeautifulSoup
  5.  
  6. session = requests.Session()
  7. session.headers.update({'User-Agent': 'Chrome'})
  8.  
  9.  
  10. def parse_web(url):
  11.     response = session.get(url)
  12.     soup = BeautifulSoup(response.text, 'html.parser')
  13.  
  14.     for link in soup.find_all('div', {'class': 'image'}):
  15.         for img in link.find_all('img'):
  16.             print(img.get('src'))
  17.  
  18.             r = requests.get(img.get('src'))
  19.             if r.status_code == 200:
  20.                 file = open(img.get('src').split('/')[-1], 'wb')
  21.                 file.write(r.content)
  22.  
  23.  
  24. parse_web('http://dota.reactor.cc/tag/Dota%2BArt/new')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement