jonathanjordan21 commited on
Commit
ae0b5d8
·
verified ·
1 Parent(s): 538543b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -24,8 +24,9 @@ app.add_middleware(
24
  )
25
 
26
  @app.get("/linkedin_post_details")
27
- async def linkedin_post_details(post_id: str):
28
- url = "https://www.linkedin.com/posts/"+post_id
 
29
  res = requests.get(url, headers={"user-agent":"Googlebot", "accept-language": "en-US"})
30
 
31
  soup = BeautifulSoup(res.content, "html.parser")
@@ -121,8 +122,9 @@ async def linkedin_post_details(post_id: str):
121
 
122
 
123
  @app.get("/facebook_post_detail")
124
- async def fb_post_detail(username: str, post_id: str):
125
- url = f"https://www.facebook.com/{username}/posts/{post_id}"
 
126
  user_agent = "Googlebot"
127
 
128
  res = requests.get(
@@ -219,12 +221,15 @@ async def google_search(q: str, delimiter: str = "\n---\n", sites: Annotated[lis
219
 
220
 
221
  @app.get("/tiktok_video_details")
222
- async def tiktok_video_details(username: str, video_id:str):
223
- if username[0] != "@":
224
- username = "@" + username
225
- url = f"https://www.tiktok.com/{username}/video/{video_id}"
 
 
226
  # user_agent = "LinkedInBot"
227
  user_agent = "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)"
 
228
  res = requests.get(url, headers={"user-agent": user_agent})
229
 
230
  # soup = BeautifulSoup(res.content, "html.parser")
 
24
  )
25
 
26
  @app.get("/linkedin_post_details")
27
+ async def linkedin_post_details(post_id: str, url: Optional[str] = None):
28
+ if not url:
29
+ url = "https://www.linkedin.com/posts/"+post_id
30
  res = requests.get(url, headers={"user-agent":"Googlebot", "accept-language": "en-US"})
31
 
32
  soup = BeautifulSoup(res.content, "html.parser")
 
122
 
123
 
124
  @app.get("/facebook_post_detail")
125
+ async def fb_post_detail(username: str, post_id: str, url: Optional[str] = None):
126
+ if not url:
127
+ url = f"https://www.facebook.com/{username}/posts/{post_id}"
128
  user_agent = "Googlebot"
129
 
130
  res = requests.get(
 
221
 
222
 
223
  @app.get("/tiktok_video_details")
224
+ async def tiktok_video_details(username: str, video_id:str, url: Optional[str] = None):
225
+ if not url:
226
+ if username[0] != "@":
227
+ username = "@" + username
228
+ url = f"https://www.tiktok.com/{username}/video/{video_id}"
229
+
230
  # user_agent = "LinkedInBot"
231
  user_agent = "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)"
232
+
233
  res = requests.get(url, headers={"user-agent": user_agent})
234
 
235
  # soup = BeautifulSoup(res.content, "html.parser")