Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 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/54.0.2840.71'})
  8.  
  9. def parse_web(url):
  10.     response = session.get(url)
  11.     soup = BeautifulSoup(response.text, 'html.parser')
  12.  
  13.     for link in soup.find_all('a', {'class': 'prettyPhotoLink'}):
  14.         print(link.get('href'))
  15.         r = requests.get(link.get('href'))
  16.  
  17.         if r.status_code == 200:
  18.             file = open(link.get('href').split('/')[-1], 'wb')
  19.             file.write(r.content)
  20.  
  21. parse_web('http://dota.reactor.cc/tag/Dota%2BArt/new')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement