Roozeec commited on
Commit
4081ce7
1 Parent(s): 244d71b

Added number of pages to read

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +10 -4
  3. 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
- "lang": "fr",
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
- settings["lang"] = st.selectbox("Select Language", ["en", "fr"])
32
- settings["region"] = st.selectbox("Select Country", ["US", "FR"])
 
 
 
 
 
 
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
- result = googlenews.result()
15
- df = pd.DataFrame(result)
 
 
 
 
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