fork download
  1. import urllib.request, re
  2. page = urllib.request.urlopen('http://l...content-available-to-author-only...a.ru/').read().decode()
  3. page = page.split('\n')
  4. a = page.index('<h2 class="bordered-title">Главное за сутки</h2>')
  5. b = page[a:].index('</section>')
  6. now = list(filter(lambda x : any(1040<=ord(k)<=1103 for k in x), page[a:a+b]))
  7. news = 'http://l...content-available-to-author-only...a.ru'
  8. print('Главное за сутки:\n '.center(50))
  9. for i in now[1:]:
  10. if 'a href' in i:
  11. print(re.sub(r'&[^а-яА-Я0-9]*', ' ', re.search(r'(?!>)[^<>]+(?=<)', i).group()))
  12. print(news+re.search(r'(\/news.+)(?=\")', i).group())
  13. print(' ')
  14. elif 'g-time' in i:
  15. print(re.search(r'\d{2}:\d{2},\s{1}[а-я0-9 ]+\d{4}', i).group())
  16. else:
  17. print(i)
  18. input()
Runtime error #stdin #stdout #stderr 0.34s 15344KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "/usr/lib/python3.2/urllib/request.py", line 1140, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python3.2/http/client.py", line 970, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.2/http/client.py", line 1008, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.2/http/client.py", line 966, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.2/http/client.py", line 811, in _send_output
    self.send(msg)
  File "/usr/lib/python3.2/http/client.py", line 749, in send
    self.connect()
  File "/usr/lib/python3.2/http/client.py", line 727, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python3.2/socket.py", line 397, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./prog.py", line 2, in <module>
  File "/usr/lib/python3.2/urllib/request.py", line 139, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.2/urllib/request.py", line 370, in open
    response = self._open(req, data)
  File "/usr/lib/python3.2/urllib/request.py", line 388, in _open
    '_open', req)
  File "/usr/lib/python3.2/urllib/request.py", line 348, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.2/urllib/request.py", line 1160, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.2/urllib/request.py", line 1143, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>