
import webbrowser
from sys import argv
from urllib.parse import parse_qs, quote

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
					UpperCamelCase_						=						"%20".join(argv[1:]) if len(argv) > 1 else quote(str(input("Search: ")))

					print("Googling.....")

					UpperCamelCase_						=						F'''https://www.google.com/search?q={query}&num=100'''

					UpperCamelCase_						=						requests.get(
					    url,
					    headers={"User-Agent": str(UserAgent().random)},
					)

					try:
										UpperCamelCase_						=						(
										    BeautifulSoup(res.text, "html.parser")
										    .find("div", attrs={"class": "yuRUbf"})
										    .find("a")
										    .get("href")
										)

					except AttributeError:
										UpperCamelCase_						=						parse_qs(
										    BeautifulSoup(res.text, "html.parser")
										    .find("div", attrs={"class": "kCrYT"})
										    .find("a")
										    .get("href")
										)["url"][0]

					webbrowser.open(link)




from __future__ import annotations



def 		lowerCAmelCase__     (       UpperCamelCase_					:							dict			,							UpperCamelCase_					:							str						)->	set[str]:
    A__			,						A__					=       set(UpperCamelCase_						), [start]

    while stack:
        A__					=       stack.pop()
        explored.add(UpperCamelCase_						)
        # Differences from BFS:
        # 1) pop last element instead of first one
        # 2) add adjacent elements to stack without exploring them
        for adj in reversed(graph[v]						):
            if adj not in explored:
                stack.append(UpperCamelCase_						)
    return explored


_lowercase    	=		{
    "A": ["B", "C", "D"],
    "B": ["A", "D", "E"],
    "C": ["A", "F"],
    "D": ["B", "D"],
    "E": ["B", "F"],
    "F": ["C", "E", "G"],
    "G": ["F"],
}

if __name__ == "__main__":
   import doctest

   doctest.testmod()
   print(depth_first_search(G, "A"))
