en/ProgrammingRobotsCourse/GettingWwwInfo: news.py
File news.py, 458 bytes (added by , 3 years ago) |
---|
Line | |
---|---|
1 | #!/usr/bin/python3 |
2 | # -*- coding: utf-8 -*- |
3 | try: |
4 | from BeautifulSoup import BeautifulSoup |
5 | except: |
6 | from bs4 import BeautifulSoup |
7 | |
8 | import requests |
9 | |
10 | def main(): |
11 | url = 'https://ihned.cz' |
12 | page = requests.get(url).text |
13 | results = [] |
14 | soup = BeautifulSoup(page, features="lxml") |
15 | results = soup.findAll('h3', attrs={'class':'article-title'}) |
16 | for result in results[0:10]: |
17 | print(result.text) |
18 | |
19 | if __name__ == "__main__": |
20 | main() |
21 |