Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
27 changes: 27 additions & 0 deletions ReaderView/Parsing/readerView.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from newspaper import Article


def reader_json(url):
article = Article(url)
article.download()
article.parse()
title = article.title
date_time = article.publish_date
if date_time is not None:
date = date_time.strftime("%d-%b-%Y")
else:
date = ""
desc = article.meta_description if article.meta_description is not None else ""
text = article.text if article.text is not None else ""
author = article.authors[0] if len(article.authors) > 0 else ""
image = article.top_image if article.top_image is not None else ""
reader = {
"title": title,
"author": author,
"date": date,
"text": text,
"image": image,
"description": desc,
"url": url
}
return reader
32 changes: 32 additions & 0 deletions ReaderView/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Reader View

## INSTALLATIONS
Install newspaper module in python 3.5
```
pip3 install newspaper3k
```
Install requests module
```
pip install requests
```
Install Regular Expressions module
```
pip install regex
```
Install Natural Language Toolkit module
```
pip install nltk
```

For api calls, run the apiMaster.py module for local calls:
```
python apiMaster.py
```
## USAGE

Goto:
```
http://localhost:5000/readerView/?url=<enter_url>&ret=<json/html>
```
Returns a JSON object if ret = json
Returns a html page if ret = html
42 changes: 42 additions & 0 deletions ReaderView/apiMaster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Parsing.readerView

from flask import Flask, request, render_template
from flask_restful import Api

app = Flask(__name__)
api = Api(app)


@app.route('/')
def showpaths():
paths = "Use path /readerView/"
return paths


@app.route('/readerView/')
def getreader():
if 'url' in request.args:
if 'ret' in request.args:
if request.args['ret'] == 'json':
return Parsing.readerView.reader_json(request.args['url'])
elif request.args['ret'] == 'html':
value = Parsing.readerView.reader_json(request.args['url'])
return render_template('reader.html',
title=value['title'],
author=value['author'],
date=value['date'],
text=value['text'],
image=value['image'],
description=value['description'],
url=value['url']
)
else:
return 'ret = html or json'
else:
return 'Provide return type ret'
else:
return 'Provide url in query'


if __name__ == '__main__':
app.run()
16 changes: 16 additions & 0 deletions ReaderView/templates/reader.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ title }}</title>
</head>
<body>
<h1>{{ title }}</h1>
<h3>{{ description }}</h3>
<h5>{{ date }} {{ author }}</h5>
<img src = '{{ image }}'> <br>
<span style="white-space: pre-wrap">
{{ text }}
</span> <br><br>
<center><h4><i>For the complete article, <a href = '{{ url }}'>Click here.</a></i></h4></center>
</body>
</html>
34 changes: 34 additions & 0 deletions Searching/LinearSearch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[10], i, num, n, c=0, pos;
cout<<"Enter the array size : ";
cin>>n;
cout<<"Enter Array Elements : ";
for(i=0; i<n; i++)
{
cin>>arr[i];
}
cout<<"Enter the number to be search : ";
cin>>num;
for(i=0; i<n; i++)
{
if(arr[i]==num)
{
c=1;
pos=i+1;
break;
}
}
if(c==0)
{
cout<<"Number not found..!!";
}
else
{
cout<<num<<" found at position "<<pos;
}
getch();
}