Created
October 8, 2025 04:46
-
-
Save jeremiahlangner/203875544da65c4c2dd951d940265ae8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as request from "request-promise-native"; | |
| import { parse, HTMLElement } from "node-html-parser"; | |
| const emailDomainLUT = { | |
| "alltel": "message.alltel.com", | |
| "AT&T": "txt.att.net", | |
| "verizon": "vtext.com", | |
| "nextel": "messaging.nextel.com", | |
| "uscellular": "mms.uscc.net", | |
| "sprint": "messaging.sprintpcs.com", | |
| "virginmobile": "vmobl.com", | |
| "tmobile": "tmomail.net" | |
| }; | |
| // Add authentication handlers... | |
| export async function handler(event, context, callback) { | |
| try { | |
| console.log(context); | |
| return callback(null, { | |
| statusCode: 200, | |
| body: await getPhoneInfo(JSON.parse(event.body).number) | |
| }); | |
| } catch (e) { | |
| console.log(e); | |
| return callback(null, { | |
| statusCode: 500, | |
| body: JSON.stringify(e) | |
| }); | |
| } | |
| } | |
| async function getPhoneInfo(num: string) { | |
| const page = await request.get({ | |
| uri: `http://www.fonefinder.net/findome.php?npa=${num.slice(0,3)}&nxx=${num.slice(3, 6)}&thoublock=${num.slice(-4)}&usaquerytype=Search+by+Number&cityname=` | |
| }); | |
| const tableStart = page.indexOf("<TABLE border=3"); | |
| const tableEnd = page.slice(tableStart).indexOf('</TABLE>')+8; | |
| const table = page.slice(tableStart, tableStart + tableEnd) | |
| const carrierInfo = await parsePageValues(table); | |
| const carrierDomain = emailDomainLUT[carrierInfo.carrier]; | |
| const email = `${num}@${carrierDomain}`; | |
| carrierInfo.email = email; | |
| return JSON.stringify(carrierInfo); | |
| } | |
| async function parsePageValues(html: string) { | |
| const table = parse(html); | |
| const tableElement: HTMLElement = (table as HTMLElement).querySelector('TABLE'); | |
| const carrierPage = await request.get({ | |
| uri: tableElement.querySelectorAll("A")[2].attributes.HREF | |
| }); | |
| const carrier = (parse(carrierPage) as HTMLElement).querySelectorAll('font')[2].text.slice(38).replace('\n', ''); | |
| return { | |
| carrier: carrier, | |
| city: tableElement.childNodes[15].rawText, | |
| email: "" | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment