Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,8 @@ import pandas as pd
|
|
20 |
import concurrent.futures
|
21 |
from duckduckgo_search import DDGS
|
22 |
from supabase import create_client, Client
|
|
|
|
|
23 |
|
24 |
# Required for saving the query & response in DB
|
25 |
db_url: str = os.environ.get("SUPABASE_URL")
|
@@ -226,7 +228,6 @@ def get_the_ticker(stock_name):
|
|
226 |
@time_logger
|
227 |
async def get_the_ticker_stat(stock):
|
228 |
try:
|
229 |
-
print(stock)
|
230 |
combination=[]
|
231 |
url = f'https://www.google.com/search?q={urllib.parse.quote(stock)}+site:businesstoday.in/stocks/&num=1&sca_esv=28795b6719ac1a08&sxsrf=ACQVn08xDA1EP1V6hJ-q4jLjjXSWWxgHTw:1711450545062&source=lnt&tbs=li:1&sa=X&ved=2ahUKEwj426eO4pGFAxX4n2MGHRXqBTUQpwV6BAgBEBM&biw=1280&bih=567&dpr=1.5'
|
232 |
# logging.info("getting ticker stat url from: %s", url)
|
@@ -240,9 +241,11 @@ async def get_the_ticker_stat(stock):
|
|
240 |
url = (links[0].split("&"))[0]
|
241 |
# logging.info("Final URL to fetch stats %s" , url)
|
242 |
# Fetch the HTML content of the webpage
|
243 |
-
|
|
|
|
|
|
|
244 |
soup = BeautifulSoup(html_content, "html.parser")
|
245 |
-
print(soup)
|
246 |
script = soup.find("script", type="application/ld+json")
|
247 |
|
248 |
# Parse the JSON-LD script
|
|
|
20 |
import concurrent.futures
|
21 |
from duckduckgo_search import DDGS
|
22 |
from supabase import create_client, Client
|
23 |
+
from requests_html import HTMLSession
|
24 |
+
|
25 |
|
26 |
# Required for saving the query & response in DB
|
27 |
db_url: str = os.environ.get("SUPABASE_URL")
|
|
|
228 |
@time_logger
|
229 |
async def get_the_ticker_stat(stock):
|
230 |
try:
|
|
|
231 |
combination=[]
|
232 |
url = f'https://www.google.com/search?q={urllib.parse.quote(stock)}+site:businesstoday.in/stocks/&num=1&sca_esv=28795b6719ac1a08&sxsrf=ACQVn08xDA1EP1V6hJ-q4jLjjXSWWxgHTw:1711450545062&source=lnt&tbs=li:1&sa=X&ved=2ahUKEwj426eO4pGFAxX4n2MGHRXqBTUQpwV6BAgBEBM&biw=1280&bih=567&dpr=1.5'
|
233 |
# logging.info("getting ticker stat url from: %s", url)
|
|
|
241 |
url = (links[0].split("&"))[0]
|
242 |
# logging.info("Final URL to fetch stats %s" , url)
|
243 |
# Fetch the HTML content of the webpage
|
244 |
+
session = HTMLSession()
|
245 |
+
response = session.get(url)
|
246 |
+
response.html.render(sleep=1)
|
247 |
+
html_content = response.html.html
|
248 |
soup = BeautifulSoup(html_content, "html.parser")
|
|
|
249 |
script = soup.find("script", type="application/ld+json")
|
250 |
|
251 |
# Parse the JSON-LD script
|