en/ProgrammingRobotsCourse/GettingWwwInfo: news.py

File news.py, 389 bytes (added by xrambous, 3 months ago)
Line 
1#!/usr/bin/python3
2# -*- coding: utf-8 -*-
3from BeautifulSoup import BeautifulSoup
4import requests
5
6def main():
7    url = 'https://ihned.cz'
8    page = requests.get(url).text
9    results = []
10    soup = BeautifulSoup(page)
11    results = soup.findAll('h2', attrs={'class':'article-title'})
12    for result in results[0:10]:
13        print(result.text)
14
15if __name__ == "__main__":
16    main()
17