-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
55 lines (53 loc) · 2.25 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from flask import Flask,url_for,render_template,request
from bs4 import BeautifulSoup
import requests
app = Flask(__name__)
@app.route('/',methods=["GET","POST"])
def index():
url = "https://www.businesstoday.in/technology/news"
req = requests.get(url)
soup = BeautifulSoup(req.content, 'html.parser')
#outerData = soup.find_all("div",class_="widget-listing",limit=6)
#print(outerData)
TechfinalNews=""
for data in soup.find_all("div",class_="widget-listing",limit=6):
news=data.div.div.a["title"]
TechfinalNews += '\u2022 '+news+'\n'
#print(finalNews)
url = "https://www.businesstoday.in/latest/corporate"
req = requests.get(url)
soup = BeautifulSoup(req.content, 'html.parser')
BuisnessfinalNews=""
for data in soup.find_all("div",class_="widget-listing",limit=6):
news=data.div.div.a["title"]
BuisnessfinalNews += '\u2022 '+news+'\n'
url = "https://indianexpress.com/section/political-pulse/"
req = requests.get(url)
soup = BeautifulSoup(req.content, 'html.parser')
finalPoliNews=""
#print(soup.find_all("div",class_="second-stories",limit=6))
news=soup.find_all("h2",class_="title",limit=7)
for data in news:
new=(str)(data.a)
ind=new.index(">")
new=new[ind+1:len(new)-4]
finalPoliNews+="\u2022"+new+"\n"
url = "https://www.businesstoday.in/latest/corporate"
req = requests.get(url)
soup = BeautifulSoup(req.content, 'html.parser')
BuisnessfinalNews=""
for data in soup.find_all("div",class_="widget-listing",limit=6):
news=data.div.div.a["title"]
BuisnessfinalNews += '\u2022 '+news+'\n'
url = "https://indianexpress.com/section/sports/"
req = requests.get(url)
soup = BeautifulSoup(req.content, 'html.parser')
finalSportNews=""
#print(soup.find_all("div",class_="second-stories",limit=6))
news=soup.find_all("h2",class_="title",limit=7)
for data in news:
new=(str)(data.a)
ind=new.index(">")
new=new[ind+1:len(new)-4]
finalSportNews+="\u2022"+new+"\n"
return render_template("index.html",Tech_News=TechfinalNews,Buisness_News=BuisnessfinalNews,Poli_News=finalPoliNews,Sport_News=finalSportNews)