Webmazta
Standardized Gemini SDK to legacy google-generativeai and fixed gemini-2.5-flash compatibility
b23cb24 Download debug_apify_final.py from webmazta/contentai: direct link, hf CLI and curl.
- Browser
- Download file 1.96 kB
-
https://huggingface.co/spaces/webmazta/contentai/resolve/main/debug_apify_final.py
- Command line
-
hf download hf://spaces/webmazta/contentai/debug_apify_final.py
-
curl -L -o debug_apify_final.py https://huggingface.co/spaces/webmazta/contentai/resolve/main/debug_apify_final.py
1.96 kB
| import json | |
| from apify_client import ApifyClient | |
| def convert_cookies_to_apify(cookies_txt_path): | |
| cookies = [] | |
| try: | |
| with open(cookies_txt_path, 'r') as f: | |
| for line in f: | |
| if not line.strip() or line.startswith('#'): | |
| continue | |
| parts = line.strip().split('\t') | |
| if len(parts) >= 7: | |
| cookie = { | |
| "domain": parts[0], | |
| "httpOnly": parts[1] == "TRUE", | |
| "path": parts[2], | |
| "secure": parts[3] == "TRUE", | |
| "expires": int(parts[4]) if parts[4].isdigit() else 0, | |
| "name": parts[5], | |
| "value": parts[6] | |
| } | |
| cookies.append(cookie) | |
| except Exception as e: | |
| print(f"Error reading cookies: {e}") | |
| return cookies | |
| client = ApifyClient("apify_api_fKPm5qA9w1u7Gy00uWdJenHks0mCvj2rFeg5") | |
| cookies = convert_cookies_to_apify("cookies.txt") | |
| run_input = { | |
| "directUrls": ["https://www.instagram.com/p/DVgO7VqlbyC/"], | |
| "resultsType": "details", | |
| "proxyConfiguration": { | |
| "useApifyProxy": True, | |
| "apifyProxyGroups": ["RESIDENTIAL"] | |
| } | |
| } | |
| if cookies: | |
| # Most Apify Instagram scrapers don't take raw cookies but take a 'sessionEncoding' | |
| # For now let's just try to see if it works without for this specific actor | |
| # Actually let's just try to find an actor that TRULY downloads media. | |
| pass | |
| print("Running Apify Actor apify/instagram-scraper...") | |
| run = client.actor("apify/instagram-scraper").call(run_input=run_input) | |
| print("Fetching results...") | |
| items = list(client.dataset(run["defaultDatasetId"]).iterate_items()) | |
| if items: | |
| with open("apify_debug_final.json", "w", encoding="utf-8") as f: | |
| json.dump(items[0], f, indent=2) | |
| print("Saved results to apify_debug_final.json") | |
| else: | |
| print("No items found.") | |