|
1 |
| -import webbrowser |
2 | 1 | import requests
|
3 | 2 | from bs4 import BeautifulSoup
|
4 | 3 | from tabulate import tabulate
|
5 | 4 | import sys
|
6 | 5 | from functools import partial
|
7 |
| -from win10toast_click import ToastNotifier |
8 |
| - |
9 | 6 |
|
10 | 7 | # think of requests as the browser who grabs the url
|
11 | 8 | res = requests.get('https://news.ycombinator.com/news')
|
12 | 9 | res2 = requests.get('https://news.ycombinator.com/news?p=2')
|
13 |
| -# print(res.text) # returns html code |
14 | 10 |
|
15 |
| -# to parse into HTML |
| 11 | +# parse into HTML |
16 | 12 | soup = BeautifulSoup(res.text, 'html.parser')
|
17 | 13 | soup2 = BeautifulSoup(res2.text, 'html.parser')
|
18 | 14 |
|
|
26 | 22 | all_subtexts = subtext + subtext2
|
27 | 23 |
|
28 | 24 |
|
29 |
| -def launch_page(): |
30 |
| - webbrowser.open('index.html') |
31 |
| - |
32 |
| - |
33 | 25 | def sort_stories_by_votes(hnlist):
|
34 | 26 |
|
35 | 27 | return sorted(hnlist, key=lambda k: k['votes'], reverse=True)
|
@@ -61,23 +53,19 @@ def create_custom_hn(links, subtext):
|
61 | 53 | fileout = open('html-table.html', 'w')
|
62 | 54 |
|
63 | 55 | html_body = """
|
64 |
| -<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Coffe Break</title><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"></head><body> |
| 56 | +<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;900&display=swap" rel="stylesheet"><link rel="stylesheet" type="text/css" href="inner_table.css"><title>Coffe Break</title></head><body> |
65 | 57 | """
|
66 | 58 |
|
67 | 59 | html_footer = """
|
68 |
| -<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> <script src="js/main.js"></script> <script src="js/main.js"></script> |
| 60 | +<script src="js/main.js"></script> |
69 | 61 | <script>
|
70 |
| - apply(); |
| 62 | + apply_style(); |
71 | 63 | </script> </body></html>
|
72 | 64 | """
|
73 | 65 |
|
74 |
| -fileout.writelines(html_body) |
75 |
| -fileout.writelines(html_table) |
76 |
| -fileout.writelines(html_footer) |
77 |
| -fileout.close() |
78 |
| - |
79 | 66 |
|
80 |
| -# experimental |
81 |
| -toast = ToastNotifier() |
82 |
| -toast.show_toast('Time for a break?', 'You should go and get some coffee.', |
83 |
| - duration=30, callback_on_click=launch_page) |
| 67 | +def update_file(): |
| 68 | + fileout.writelines(html_body) |
| 69 | + fileout.writelines(html_table) |
| 70 | + fileout.writelines(html_footer) |
| 71 | + fileout.close() |
0 commit comments