Compare commits

...

3 commits

Author SHA1 Message Date
Edward Betts e5225ba239 Fix search for S&P Total Market 2023-11-25 16:06:37 +00:00
Edward Betts 4638c710d5 Don't include bad state in one line output 2023-11-25 16:06:37 +00:00
Edward Betts 1a5ed90fc1 Request UK version of Google
Closes: #2
2023-11-25 16:06:29 +00:00
2 changed files with 4 additions and 6 deletions

View file

@ -81,7 +81,8 @@ class Index:
@property @property
def search_url(self) -> str: def search_url(self) -> str:
"""Search URL.""" """Search URL."""
return "https://www.google.com/search?q=" + urllib.parse.quote_plus(self.name) q = urllib.parse.quote_plus(self.name)
return f"https://www.google.com/search?q={q}&gl=uk"
def run(self, playwright: Playwright) -> None: def run(self, playwright: Playwright) -> None:
"""Run playwright.""" """Run playwright."""
@ -145,7 +146,4 @@ class Index:
@property @property
def one_line(self) -> str: def one_line(self) -> str:
"""Index name, price and price change.""" """Index name, price and price change."""
return ( return f"{self.title}: {self.price} ({self.percent_change}%) {self.timestamp}"
f"{self.title}: {self.price} ({self.percent_change}%) "
+ f"{self.state} {self.timestamp}"
)

View file

@ -3,6 +3,6 @@
from google_stocks import Index from google_stocks import Index
index = Index("S&P Total Market") index = Index("SPTMI")
print(index.one_line) print(index.one_line)