input: Write a python function to convert a URL to a PDF file.
  assert generate_pdf("http://example.com") == "example.com.pdf"
  assert generate_pdf("https://www.google.com") == "www.google.com.pdf"
  assert generate_pdf("http://my.website.org/page") == "page.pdf"
output: def generate_pdf(url):
      import re
      pattern = r'http[s]?://(?:www\.)?([^/]+/)?([^/?#]+)'
      match = re.search(pattern, url)
      if match:
          filename = match.group(2)
          if not filename:
              filename = match.group(1).rstrip('/')
          return f"{filename}.pdf"
      return None