PepperWorkshop/GettingWwwInfo: news.py
File news.py, 389 bytes (added by , 4 years ago) |
---|
Line | |
---|---|
1 | #!/usr/bin/python3 |
2 | # -*- coding: utf-8 -*- |
3 | from BeautifulSoup import BeautifulSoup |
4 | import requests |
5 | |
6 | def 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 | |
15 | if __name__ == "__main__": |
16 | main() |
17 |