Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,8 @@ import requests
|
|
7 |
import httpx
|
8 |
import re
|
9 |
import json
|
|
|
|
|
10 |
|
11 |
from fastapi.middleware.cors import CORSMiddleware
|
12 |
|
@@ -26,6 +28,18 @@ app.add_middleware(
|
|
26 |
)
|
27 |
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
@app.get("/linkedin_post_details")
|
30 |
async def linkedin_post_details(post_id: Optional[str] = None, url: Optional[str] = None):
|
31 |
if not url:
|
|
|
7 |
import httpx
|
8 |
import re
|
9 |
import json
|
10 |
+
import newspaper
|
11 |
+
|
12 |
|
13 |
from fastapi.middleware.cors import CORSMiddleware
|
14 |
|
|
|
28 |
)
|
29 |
|
30 |
|
31 |
+
@shared_task
|
32 |
+
def news_details(url: str):
|
33 |
+
article = newspaper.Article(url)
|
34 |
+
article.download()
|
35 |
+
article.parse()
|
36 |
+
return {
|
37 |
+
"title": article.title,
|
38 |
+
"description": article.text,
|
39 |
+
"author": article.author,
|
40 |
+
"date": article.publish_date,
|
41 |
+
}
|
42 |
+
|
43 |
@app.get("/linkedin_post_details")
|
44 |
async def linkedin_post_details(post_id: Optional[str] = None, url: Optional[str] = None):
|
45 |
if not url:
|