Path: blob/master/Investigation/socialMedia2.py
193 views
import asyncio1from playwright.async_api import async_playwright2from pyvirtualdisplay import Display3import time4def printAll():5return instAc6async def run(playwright,phone_number):7global page8global instAc9firefox = playwright.firefox10browser = await firefox.launch(headless=True)11context = await browser.new_context()12page = await context.new_page()13await page.goto("https://www.instagram.com/accounts/login/")14await page.locator('[name="username"]').fill(phone_number[0])15await page.locator('[name="password"]').fill(phone_number[0])16await page.click('button:has-text("Log In")')17try:18try:19await page.text_content('p:has-text("Sorry, your password was incorrect. Please double-check your password.")',timeout=3000)20instAc="True"21except:22try:23await page.text_content('p:has-text("a problem")',timeout=3000)24instAc="_False_"25except:26instAc="False"27except:28instAc="False"29await browser.close()30async def instaMain(phone_number):31async with async_playwright() as playwright:32await run(playwright,phone_number)333435