Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0c4a270

Browse files
added fetch_news_link() in helper.py
1 parent 1131342 commit 0c4a270

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

‎helper.py‎

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from cProfile import label
2-
from re import S
3-
import spacy
41
from spacy.lang.en.stop_words import STOP_WORDS
5-
from spacy import load, displacy
62
import en_core_web_sm
73
from string import punctuation
84
from heapq import nlargest
95
import spacy_streamlit
6+
import requests
7+
import json
8+
from bs4 import BeautifulSoup
109

1110

1211
nlp= en_core_web_sm.load()
@@ -50,6 +49,36 @@ def sentence_score(sentence_tokens, word_frequencies):
5049
return sentence_score
5150

5251

52+
def fetch_news_links():
53+
link_list = []
54+
55+
reqUrl = "https://newsapi.org/v2/everything?sources=bbc-news&q=india&language=en&apiKey=3af9b5b135cc4e90b4a5d87807716cd1"
56+
57+
headersList = {
58+
"Accept": "*/*",
59+
"User-Agent": "Thunder Client (https://www.thunderclient.com)"
60+
}
61+
62+
payload = ""
63+
64+
response = requests.request("GET", reqUrl, data=payload, headers=headersList).text
65+
response = json.loads(response)
66+
67+
tw = 0
68+
for i in range(len(response["articles"])):
69+
if tw ==10:
70+
pass
71+
else:
72+
if "/news/" in response["articles"][i]["url"]:
73+
link_list.append(response["articles"][i]["url"])
74+
else:
75+
pass
76+
tw += 1
77+
78+
return link_list
79+
80+
81+
5382
def get_summary(text):
5483
doc = nlp(text)
5584
tokens = [token.text for token in doc]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /