Fred808 commited on
Commit
1bcb43c
·
verified ·
1 Parent(s): 2778998

Update utils/instaloader_utils.py

Browse files
Files changed (1) hide show
  1. utils/instaloader_utils.py +8 -3
utils/instaloader_utils.py CHANGED
@@ -37,8 +37,6 @@ async def fetch_user_posts(username: str, max_posts: int = 20):
37
  raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}")
38
 
39
 
40
-
41
-
42
  def find_similar_accounts(username: str, rapidapi_key: str) -> List[str]:
43
  """
44
  Fetch similar accounts using the RapidAPI endpoint.
@@ -48,7 +46,7 @@ def find_similar_accounts(username: str, rapidapi_key: str) -> List[str]:
48
 
49
  headers = {
50
  "x-rapidapi-host": "instagram-scraper-api2.p.rapidapi.com",
51
- "x-rapidapi-key": "d14b901fa8mshdafabd10d36f007p1ff602jsn91766325646f"
52
  }
53
 
54
  try:
@@ -78,3 +76,10 @@ def fetch_competitors_data(username: str, rapidapi_key: str, max_posts: int = 50
78
  all_posts.extend(competitor_posts)
79
  return all_posts
80
 
 
 
 
 
 
 
 
 
37
  raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}")
38
 
39
 
 
 
40
  def find_similar_accounts(username: str, rapidapi_key: str) -> List[str]:
41
  """
42
  Fetch similar accounts using the RapidAPI endpoint.
 
46
 
47
  headers = {
48
  "x-rapidapi-host": "instagram-scraper-api2.p.rapidapi.com",
49
+ "x-rapidapi-key": rapidapi_key
50
  }
51
 
52
  try:
 
76
  all_posts.extend(competitor_posts)
77
  return all_posts
78
 
79
+ rapidapi_key = "d14b901fa8mshdafabd10d36f007p1ff602jsn91766325646f" # Replace with your actual RapidAPI key
80
+
81
+ try:
82
+ competitors_posts = fetch_competitors_data(username, rapidapi_key)
83
+ print("Competitors' posts:", competitors_posts)
84
+ except Exception as e:
85
+ print(f"Unexpected error: {e}")