diff --git a/ReaderView/Parsing/__pycache__/readerView.cpython-35.pyc b/ReaderView/Parsing/__pycache__/readerView.cpython-35.pyc new file mode 100644 index 0000000..8d3fc60 Binary files /dev/null and b/ReaderView/Parsing/__pycache__/readerView.cpython-35.pyc differ diff --git a/ReaderView/Parsing/readerView.py b/ReaderView/Parsing/readerView.py new file mode 100644 index 0000000..d798c19 --- /dev/null +++ b/ReaderView/Parsing/readerView.py @@ -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 \ No newline at end of file diff --git a/ReaderView/README.md b/ReaderView/README.md new file mode 100644 index 0000000..9308ba9 --- /dev/null +++ b/ReaderView/README.md @@ -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=&ret= +``` +Returns a JSON object if ret = json +Returns a html page if ret = html \ No newline at end of file diff --git a/ReaderView/apiMaster.py b/ReaderView/apiMaster.py new file mode 100644 index 0000000..10ec257 --- /dev/null +++ b/ReaderView/apiMaster.py @@ -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() diff --git a/ReaderView/templates/reader.html b/ReaderView/templates/reader.html new file mode 100644 index 0000000..40cef7b --- /dev/null +++ b/ReaderView/templates/reader.html @@ -0,0 +1,16 @@ + + + + {{ title }} + + +

{{ title }}

+

{{ description }}

+
{{ date }} {{ author }}
+
+ + {{ text }} +

+

For the complete article, Click here.

+ + \ No newline at end of file diff --git a/Searching/LinearSearch.cpp b/Searching/LinearSearch.cpp new file mode 100644 index 0000000..7d18ded --- /dev/null +++ b/Searching/LinearSearch.cpp @@ -0,0 +1,34 @@ +#include +#include +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>arr[i]; + } + cout<<"Enter the number to be search : "; + cin>>num; + for(i=0; i