benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 26c35822-94a0-5a87-bf6b-6a5e9a2d44cf

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import re
import urllib.parse
import ssl
import socket

def task_func(myString):
    """
    Extracts all URLs from a string and retrieves the domain and the expiration date of the SSL certificate 
    for each HTTPS URL. Only HTTPS URLs are processed; HTTP URLs are ignored. The function handles SSL errors 
    by ignoring any HTTPS URLs where the SSL certificate cannot be retrieved due to such errors, and these domains 
    are not included in the returned dictionary.

    Parameters:
    myString (str): The string from which to extract URLs.
    
    Returns:
    dict: A dictionary with domains as keys and SSL certificate expiry dates in UTC format as values. 
          The dictionary includes only those HTTPS URLs for which the SSL certificate was successfully retrieved.
          Domains with SSL errors are excluded.

    Requirements:
    - re
    - urllib.parse
    - ssl
    - socket
    
    Example:
    >>> task_func("Check these links: https://www.google.com, https://www.python.org")
    {'www.google.com': '2023-06-15 12:00:00', 'www.python.org': '2023-07-20 12:00:00'}
    """

instruct prompt

Extracts all URLs from a string and retrieves the domain and the expiration date of the SSL certificate for each HTTPS URL. Only HTTPS URLs are processed; HTTP URLs are ignored. The function handles SSL errors by ignoring any HTTPS URLs where the SSL certificate cannot be retrieved due to such errors, and these domains are not included in the returned dictionary.
The function should output with:
    dict: A dictionary with domains as keys and SSL certificate expiry dates in UTC format as values.
    The dictionary includes only those HTTPS URLs for which the SSL certificate was successfully retrieved.
    Domains with SSL errors are excluded.
You should write self-contained code starting with:

Code

import re
import urllib.parse
import ssl
import socket
def task_func(myString):

code prompt

Code

import re
import urllib.parse
import ssl
import socket
def task_func(myString):

entry point

task_func

libs

  • urllib
  • re
  • socket
  • ssl

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import