SearchEngine
Search Facebook for profiles, posts, groups, and Marketplace listings.
SearchEngine can be created with:
SearchEngine(context: FacebookContext) -> SearchEngine
Methods
search
search(query, filter_type, exact_match)-> PaginatedIterator[Profile | Post | Group]Search for profiles, posts, or groups.
filter_type: str"all","profile","post", or"group"."all"yields a mix ofProfile,Post, andGroup.exact_match: boolTruerequires an exact match. Defaults toFalse(fuzzy matching).
search_marketplace
search_marketplace(query, is_stock_available, filter_location_latitude, filter_location_longitude, filter_price_lower_bound, filter_price_upper_bound, filter_radius_km, item_condition, last_n_days, sort_by)Search Marketplace listings.
is_stock_available: bool- Restrict to in-stock items.
filter_location_latitude: float- Latitude of the search center.
filter_location_longitude: float- Longitude of the search center.
filter_price_lower_bound: int- Minimum price.
filter_price_upper_bound: int- Maximum price.
filter_radius_km: int- Search radius in kilometers.
item_condition: str- Item condition:
"new","used_like_new","used_good", or"used_fair". last_n_days: int- Only include listings posted within the last N days.
sort_by: str- Sort order:
"PRICE_DESCEND","PRICE_ASCEND","DISTANCE_ASCEND", or"CREATION_TIME_DESCEND".
Example
import facebook_gql_scraper as fgs
context = fgs.FacebookContext(cookies_file="facebook_cookies.json")
engine = fgs.SearchEngine(context)
for profile in engine.search("Ishowspeed", filter_type="profile", exact_match=True):
print(profile.id, profile.name)