Skip to main content

Exceptions

FacebookGqlScraperException​

Base class for all errors raised by this library.

Session errors​

SessionExpiredError : Exception

Facebook invalidated the session — cookies expired or were revoked.
Inherits FacebookGqlScraperException.

GraphQL request errors​

SchemaChangedError : Exception

Facebook changed the GraphQL schema for an operation; the variables no longer match.
Inherits FacebookGqlScraperException.

DocIdStillInvalidError : Exception

Facebook rejected the doc_id even after re-discovery.
Inherits FacebookGqlScraperException.

DtsgTokenStillInvalidError : Exception

Facebook rejected the fb_dtsg token even after refresh.
Inherits FacebookGqlScraperException.

DtsgTokenFetchError : Exception

Failed to obtain the fb_dtsg token.
Inherits FacebookGqlScraperException.

Not found errors​

FacebookNotFoundError : Exception

Base for not-found errors. The requested resource does not exist on Facebook.
Inherits FacebookGqlScraperException.

ProfileNotFoundError : Exception

The profile was not found.
Inherits FacebookNotFoundError.

PostNotFoundError : Exception

The post was not found.
Inherits FacebookNotFoundError.

GroupNotFoundError : Exception

The group was not found.
Inherits FacebookNotFoundError.

MarketplaceListingNotFoundError : Exception

The Marketplace listing was not found.
Inherits FacebookNotFoundError.

Access errors​

FacebookAccessException : Exception

Base for access errors. Facebook refused access to the requested resource.
Inherits FacebookGqlScraperException.

ResourceNotAvailableException : Exception

The resource exists but is not exposed by this profile or group.
Inherits FacebookAccessException.

FollowersNotAvailableException : Exception

The profile does not expose its followers list.
Inherits ResourceNotAvailableException.

FolloweesNotAvailableException : Exception

The profile does not expose its following list.
Inherits ResourceNotAvailableException.

FriendFollowersNotAvailableException : Exception

The profile does not expose friends with follower relationships.
Inherits ResourceNotAvailableException.

FriendFolloweesNotAvailableException : Exception

The profile does not expose friends with following relationships.
Inherits ResourceNotAvailableException.

PhotoNotAvailableException : Exception

The profile does not expose its photos.
Inherits ResourceNotAvailableException.

ReelsNotAvailableException : Exception

The profile does not expose its reels.
Inherits ResourceNotAvailableException.

Usage errors​

MissingParentError : Exception

A model needs its parent, but none was provided — e.g. Comment.get_replies() without a parent Post.
Inherits FacebookGqlScraperException.

Example​

import facebook_gql_scraper as fgs
from facebook_gql_scraper.exceptions import ProfileNotFoundError

context = fgs.FacebookContext(cookies_file="facebook_cookies.json")

try:
user = fgs.Profile.from_username(context, username="doesnotexist123")
except ProfileNotFoundError:
print("No such profile")