





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__":
  _A					:				Optional[int]				=			"""%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """)))

  print("""Googling.....""")

  _A					:				Optional[int]				=			F'https://www.google.com/search?q={query}&num=100'

  _A					:				Optional[int]				=			requests.get(
      url,
      headers={"""User-Agent""": str(UserAgent().random)},
  )

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

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

  webbrowser.open(link)







import pytest
import requests

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline


@pytest.mark.integration
def 							__snake_case							(    )				->						Any:
    with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT	):
        with pytest.raises(lowerCAmelCase_	):
            requests.request('''GET''' ,							'''https://huggingface.co'''	)
        with pytest.raises(requests.exceptions.ConnectTimeout	):
            requests.request('''GET''' ,							'''https://huggingface.co''' ,							timeout=1.0	)


@pytest.mark.integration
def 							__snake_case							(    )				->						int:
    with offline(OfflineSimulationMode.CONNECTION_FAILS	):
        with pytest.raises(requests.exceptions.ConnectionError	):
            requests.request('''GET''' ,							'''https://huggingface.co'''	)



def 							__snake_case							(    )				->						List[Any]:
    with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1	):
        with pytest.raises(lowerCAmelCase_	):
            http_head('''https://huggingface.co'''	)
