Kosty_Fomin

Untitled

Feb 28th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1.  
  2.  
  3. Задача 6 (4 балла)
  4. def get_languages_hse(last_name):
  5.     def get_teacher_url(last_name):
  6.         url = 'https://www.hse.ru/org/hse/ouk/hmat/persons'
  7.         import bs4
  8.         import urllib.request
  9.  
  10.         try:
  11.             f = urllib.request.urlopen(url)
  12.             soup = bs4.BeautifulSoup(f.read(), "html.parser")
  13.             s = None
  14.             for a in soup.find_all(['a'], {'class': 'fa-person__name'}):
  15.                 if last_name in a.text:
  16.                     return 'http://' + a['href'][2:]
  17.         except:
  18.             return None
  19.     # coding=utf8
  20.     url = get_teacher_url(last_name)
  21.  
  22.     import bs4
  23.     import urllib.request
  24.     res = []
  25.  
  26.     try:
  27.         f = urllib.request.urlopen(url)
  28.         soup = bs4.BeautifulSoup(f.read(), "html.parser")
  29.         for a in soup.find_all(['dl'],{'class':'main-list large main-list-language-knowledge-level'}):
  30.             for r in a.find_all('dd'):
  31.                 res.append(r.text)
  32.             return res
  33.     except:
  34.         pass
Advertisement
Add Comment
Please, Sign In to add comment