Skip to content

Commit

Permalink
Remove Pastebin from platforms
Browse files Browse the repository at this point in the history
Newly-added site protection for Pastebin means that it is no longer possible for
socialscan to reliably retrieve username/email usage data for the
platform
  • Loading branch information
iojw committed Aug 12, 2020
1 parent 462f8ef commit e4a3b29
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 54 deletions.
2 changes: 1 addition & 1 deletion socialscan/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.3"
__version__ = "1.3.0"
53 changes: 0 additions & 53 deletions socialscan/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,58 +456,6 @@ async def check_email(self, email):
return self.response_available(email, message=message)


class Pastebin(PlatformChecker):
URL = "https://pastebin.com/signup"
ENDPOINT = "https://pastebin.com/signup"
USERNAME_TAKEN_MSGS = ["This username has already been taken."]
USERNAME_LINK_FORMAT = "https://pastebin.com/u/{}"

token_regex = re.compile(r"<meta name=\"csrf-token\" content=\"([\S]+)\">")

async def prerequest(self):
async with self.get(Pastebin.URL) as r:
text = await r.text()
match = self.token_regex.search(text)
if match:
token = match.group(1)
return (token, r.cookies)

async def check_username(self, username):
token, cookies = await self.get_token()
data = {"_csrf-frontend": token, "SignupForm[username]": username, "ajax": "js-signup-form"}
async with self.post(
Pastebin.ENDPOINT,
data=data,
cookies=cookies,
headers={"X-Requested-With": "XMLHttpRequest"},
) as r:
json_body = await self.get_json(r)
if "signupform-username" in json_body:
return self.response_unavailable_or_invalid(
username,
message=json_body["signupform-username"][0],
unavailable_messages=Pastebin.USERNAME_TAKEN_MSGS,
link=Pastebin.USERNAME_LINK_FORMAT.format(username),
)
else:
return self.response_available(username)

async def check_email(self, email):
token, cookies = await self.get_token()
data = {"_csrf-frontend": token, "SignupForm[email]": email, "ajax": "js-signup-form"}
async with self.post(
Pastebin.ENDPOINT,
data=data,
cookies=cookies,
headers={"X-Requested-With": "XMLHttpRequest"},
) as r:
json_body = await self.get_json(r)
if "signupform-email" in json_body:
return self.response_unavailable(email, message=json_body["signupform-email"][0])
else:
return self.response_available(email)


class Pinterest(PlatformChecker):
URL = "https://www.pinterest.com"
EMAIL_ENDPOINT = "https://www.pinterest.com/_ngjs/resource/EmailExistsResource/get/"
Expand Down Expand Up @@ -659,7 +607,6 @@ class Platforms(Enum):
GITLAB = GitLab
INSTAGRAM = Instagram
LASTFM = Lastfm
PASTEBIN = Pastebin
PINTEREST = Pinterest
REDDIT = Reddit
SNAPCHAT = Snapchat
Expand Down

0 comments on commit e4a3b29

Please sign in to comment.