Spaces:
Running
Running
Added number of pages to read
Browse files- .gitignore +1 -0
- app.py +10 -4
- wna_googlenews.py +9 -2
.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1 |
__pycache__/**
|
|
|
|
1 |
__pycache__/**
|
2 |
+
.env
|
app.py
CHANGED
@@ -17,10 +17,10 @@ models = [
|
|
17 |
]
|
18 |
|
19 |
settings = {
|
20 |
-
"
|
21 |
-
"region": "FR",
|
22 |
"period": "1d",
|
23 |
"model": models[0],
|
|
|
24 |
}
|
25 |
|
26 |
|
@@ -28,8 +28,14 @@ with st.sidebar:
|
|
28 |
st.title("Settings")
|
29 |
# add language and country parameters
|
30 |
st.header("Language and Country")
|
31 |
-
|
32 |
-
settings["
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
# add period parameter
|
35 |
st.header("Period")
|
|
|
17 |
]
|
18 |
|
19 |
settings = {
|
20 |
+
"langregion": "en/US",
|
|
|
21 |
"period": "1d",
|
22 |
"model": models[0],
|
23 |
+
"number_of_pages": 5
|
24 |
}
|
25 |
|
26 |
|
|
|
28 |
st.title("Settings")
|
29 |
# add language and country parameters
|
30 |
st.header("Language and Country")
|
31 |
+
|
32 |
+
settings["langregion"] = st.selectbox("Select Language", ["en/US", "fr/FR"])
|
33 |
+
# input field for number of pages
|
34 |
+
st.header("Number of Pages")
|
35 |
+
settings["number_of_pages"] = st.number_input("Enter Number of Pages", min_value=1, max_value=10)
|
36 |
+
|
37 |
+
settings["region"] = settings["langregion"].split("/")[0]
|
38 |
+
settings["lang"] = settings["langregion"].split("/")[1]
|
39 |
|
40 |
# add period parameter
|
41 |
st.header("Period")
|
wna_googlenews.py
CHANGED
@@ -10,7 +10,14 @@ def get_news(settings, query):
|
|
10 |
region=settings["region"],
|
11 |
period=settings["period"],
|
12 |
)
|
|
|
|
|
|
|
13 |
googlenews.search(query)
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
return df
|
|
|
10 |
region=settings["region"],
|
11 |
period=settings["period"],
|
12 |
)
|
13 |
+
number_of_pages = settings["number_of_pages"]
|
14 |
+
# get each pages
|
15 |
+
final_list = []
|
16 |
googlenews.search(query)
|
17 |
+
print("Total Pages: ", googlenews.total_count())
|
18 |
+
for page in range(1, number_of_pages + 1):
|
19 |
+
page_result = googlenews.page_at(page)
|
20 |
+
# merge dat
|
21 |
+
final_list = final_list + page_result
|
22 |
+
df = pd.DataFrame(final_list)
|
23 |
return df
|