




'''simple docstring'''



from urllib.error import HTTPError

from bsa import BeautifulSoup
from requests import exceptions, get

UpperCAmelCase_    :					Optional[Any]					      =						'''https://www.wellrx.com/prescriptions/{0}/{1}/?freshSearch=true'''







def      _UpperCamelCase	(_lowerCamelCase							:       str				,		_lowerCamelCase							:       List[str]		)->				list | None:




     '''simple docstring'''





     try:
          # Has user provided both inputs?
          if not drug_name or not zip_code:
               return None

          __snake_case         =					BASE_URL.format(SCREAMING_SNAKE_CASE_				,		SCREAMING_SNAKE_CASE_		)
          __snake_case         =					get(SCREAMING_SNAKE_CASE_		)

          # Is the response ok?
          response.raise_for_status()

          # Scrape the data using bs4
          __snake_case         =					BeautifulSoup(response.text				,		'''html.parser'''		)

          # This list will store the name and price.
          __snake_case         =					[]

          # Fetch all the grids that contains the items.
          __snake_case         =					soup.find_all('''div'''				,		{'''class''': '''grid-x pharmCard'''}		)
          if grid_list and len(SCREAMING_SNAKE_CASE_		) > 0:
               for grid in grid_list:
                    # Get the pharmacy price.
                    __snake_case         =					grid.find('''p'''				,		{'''class''': '''list-title'''}		).text

                    # Get price of the drug.
                    __snake_case         =					grid.find('''span'''				,		{'''p''', '''price price-large'''}		).text

                    pharmacy_price_list.append(
                        {
                            '''pharmacy_name''': pharmacy_name,
                            '''price''': price,
                        }		)

          return pharmacy_price_list

     except (HTTPError, exceptions.RequestException, ValueError):
          return None


if __name__ == "__main__":
     # Enter a drug name and a zip code
     UpperCAmelCase_    :					Optional[int]					      =						input('''Enter drug name: ''').strip()
     UpperCAmelCase_    :					str					      =						input('''Enter zip code: ''').strip()

     UpperCAmelCase_    :					list | None					      =						fetch_pharmacy_and_price_list(
         drug_name, zip_code
     )

     if pharmacy_price_list:
          print(F"""\nSearch results for {drug_name} at location {zip_code}:""")
          for pharmacy_price in pharmacy_price_list:
               UpperCAmelCase_    :					Optional[int]					      =						pharmacy_price['''pharmacy_name''']
               UpperCAmelCase_    :					Dict					      =						pharmacy_price['''price''']

               print(F"""Pharmacy: {name} Price: {price}""")
     else:
          print(F"""No results found for {drug_name}""")









'''simple docstring'''



from __future__ import annotations

from collections.abc import Iterator
from typing import Any





class       lowerCAmelCase				:


       def __init__(				self      ,					__SCREAMING_SNAKE_CASE					) ->					None:



            '''simple docstring'''




            __snake_case         =					data
            __snake_case         =					None




       def __str__(				self					) ->					str:



            '''simple docstring'''




            return F'''{self.data}'''





class       lowerCAmelCase				:


       def __init__(				self					) ->					None:



            '''simple docstring'''




            __snake_case         =					None
            __snake_case         =					None


       def __iter__(				self					) ->					Iterator[Any]:



            '''simple docstring'''




            __snake_case         =					self.front
            while node:
                 yield node.data
                 __snake_case         =					node.next


       def __len__(				self					) ->					int:



            '''simple docstring'''




            return len(tuple(iter(self					)					)					)


       def __str__(				self					) ->					str:



            '''simple docstring'''




            return " <- ".join(str(__SCREAMING_SNAKE_CASE					) for item in self					)


       def  lowerCAmelCase (				self					) ->					bool:



            '''simple docstring'''




            return len(self					) == 0


       def  lowerCAmelCase (				self      ,					__SCREAMING_SNAKE_CASE					) ->					None:



            '''simple docstring'''




            __snake_case         =					Node(__SCREAMING_SNAKE_CASE					)
            if self.is_empty():
                 __snake_case         =					__snake_case         =					node
            else:
                 assert isinstance(self.rear      ,					__SCREAMING_SNAKE_CASE					)
                 __snake_case         =					node
                 __snake_case         =					node


       def  lowerCAmelCase (				self					) ->					Any:



            '''simple docstring'''




            if self.is_empty():
                 raise IndexError('''dequeue from empty queue'''					)
            assert isinstance(self.front      ,					__SCREAMING_SNAKE_CASE					)
            __snake_case         =					self.front
            __snake_case         =					self.front.next
            if self.front is None:
                 __snake_case         =					None
            return node.data




       def  lowerCAmelCase (				self					) ->					None:



            '''simple docstring'''




            __snake_case         =					__snake_case         =					None


if __name__ == "__main__":
     from doctest import testmod

     testmod()






