File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import httpx
2+ from user_scanner .core .result import Result
3+
4+ async def _check (email : str ) -> Result :
5+
6+ show_url = "https://boot.dev"
7+ headers = {
8+ 'Accept' : 'application/json, text/plain, */*' ,
9+ 'Accept-Language' : 'en-US,en;q=0.9' ,
10+ 'User-Agent' : "Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0" ,
11+ 'Referer' : 'https://boot.dev/' ,
12+ }
13+
14+ try :
15+ async with httpx .AsyncClient (timeout = 5.0 , follow_redirects = True ) as client :
16+ response = await client .post (
17+ "https://api.boot.dev/v1/users/email/exists" ,
18+ headers = headers ,
19+ json = {"email" : email }
20+ )
21+
22+ if response .status_code == 200 :
23+ data = response .json ()
24+ if data .get ("Exists" ) is True :
25+ return Result .taken (url = show_url )
26+ else :
27+ return Result .available (url = show_url )
28+
29+ return Result .error (f"HTTP { response .status_code } " )
30+
31+ except httpx .TimeoutException :
32+ return Result .error ("Connection timed out" )
33+ except Exception as e :
34+ return Result .error (e )
35+
36+
37+ async def validate_boot (email : str ) -> Result :
38+ return await _check (email )
Original file line number Diff line number Diff line change 1+ from user_scanner .core .helpers import get_random_user_agent
2+ from user_scanner .core .orchestrator import generic_validate
3+ from user_scanner .core .result import Result
4+
5+ def validate_boot (user ):
6+ url = f"https://www.boot.dev/u/{ user } "
7+ show_url = f"https://boot.dev/u/{ user } "
8+
9+ headers = {
10+ "User-Agent" : get_random_user_agent (),
11+ "Accept" : "application/json, text/plain, */*" ,
12+ "X-Requested-With" : "XMLHttpRequest" ,
13+ "Referer" : "https://boot.dev/" ,
14+ }
15+
16+ def process (response ):
17+ data = response .text
18+
19+ if response .status_code == 404 :
20+ return Result .available ()
21+ if "User not found" in data :
22+ return Result .available ()
23+ if response .status_code == 200 and "__NUXT__" in data and f"publicUser:{ user } " in data :
24+ return Result .taken ()
25+ return Result .error ("Unexpected response format" )
26+
27+ return generic_validate (url , process , show_url = show_url , headers = headers )
You can’t perform that action at this time.
0 commit comments