AlJohri / socialscraper

Social media scrapers
25 stars 3 forks source link

Move Facebook Auth State Machine outside of auth.py to check state on all requests #5

Open AlJohri opened 10 years ago

AlJohri commented 10 years ago

This will prevent us from doing stupid hacks like

https://github.com/alpaca/socialscraper/blob/master/socialscraper/facebook/scraper.py#L24

class FacebookSession(requests.sessions.Session):

    def get(self, url, **kwargs):
        response = super(FacebookSession, self).get(url, **kwargs)

        if not auth.state(response.text, auth.LOCKED) and not auth.state(response.text, auth.SECURITY_CHECK):
            return response
        else:
            raise ScrapingError("Account locked. Stop scraping!")

I'm only checking if its locked or security check on each request but there's a ton of other states I should be checking for.

Best to move this into its own module.