Skip to content

Commit 4f469e2

Browse files
committed
refactored code, replaced bootstrap with simple css
1 parent bf0236e commit 4f469e2

File tree

11 files changed

+247
-11467
lines changed

11 files changed

+247
-11467
lines changed
2.33 KB
Binary file not shown.

__pycache__/launch.cpython-310.pyc

1.86 KB
Binary file not shown.

launch.py renamed to content_crawler.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
import webbrowser
21
import requests
32
from bs4 import BeautifulSoup
43
from tabulate import tabulate
54
import sys
65
from functools import partial
7-
from win10toast_click import ToastNotifier
8-
96

107
# think of requests as the browser who grabs the url
118
res = requests.get('https://news.ycombinator.com/news')
129
res2 = requests.get('https://news.ycombinator.com/news?p=2')
13-
# print(res.text) # returns html code
1410

15-
# to parse into HTML
11+
# parse into HTML
1612
soup = BeautifulSoup(res.text, 'html.parser')
1713
soup2 = BeautifulSoup(res2.text, 'html.parser')
1814

@@ -26,10 +22,6 @@
2622
all_subtexts = subtext + subtext2
2723

2824

29-
def launch_page():
30-
webbrowser.open('index.html')
31-
32-
3325
def sort_stories_by_votes(hnlist):
3426

3527
return sorted(hnlist, key=lambda k: k['votes'], reverse=True)
@@ -61,23 +53,19 @@ def create_custom_hn(links, subtext):
6153
fileout = open('html-table.html', 'w')
6254

6355
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>
6557
"""
6658

6759
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>
6961
<script>
70-
apply();
62+
apply_style();
7163
</script> </body></html>
7264
"""
7365

74-
fileout.writelines(html_body)
75-
fileout.writelines(html_table)
76-
fileout.writelines(html_footer)
77-
fileout.close()
78-
7966

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

Comments
 (0)