SHARE
TWEET

Untitled

a guest Feb 22nd, 2020 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. import time
  3. from bs4 import BeautifulSoup as bs
  4.  
  5.  
  6. base_url = 'https://horoscopes.rambler.ru/'
  7. zodiac = [
  8.     'aries/', 'taurus/', 'gemini/',
  9.     'cancer/', 'leo/', 'virgo/',
  10.     'libra/', 'scorpio/', 'sagittarius/',
  11.     'capricorn/', 'aquarius/', 'pisces/'
  12. ]
  13.  
  14.  
  15. def parse():
  16.     horoscope = {}
  17.     session = requests.Session()
  18.  
  19.     for zod in zodiac:
  20.         url = base_url + zod
  21.         request = session.get(url)
  22.         if request.status_code == 200:
  23.             soup = bs(request.content, 'html.parser')
  24.  
  25.             title = soup.find(
  26.                 'div', attrs={'class': 'v0ls'}
  27.             )
  28.             title = title.find('h1').text
  29.             print(title)
  30.  
  31.  
  32. parse()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top