Format: text/x-python
⬇ Download File (964 B)
   1  import random
   2  
   3  def get_useragent():
   4      """
   5      Generates a random user agent string mimicking the format of various software versions.
   6  
   7      The user agent string is composed of:
   8      - Lynx version: Lynx/x.y.z where x is 2-3, y is 8-9, and z is 0-2
   9      - libwww version: libwww-FM/x.y where x is 2-3 and y is 13-15
  10      - SSL-MM version: SSL-MM/x.y where x is 1-2 and y is 3-5
  11      - OpenSSL version: OpenSSL/x.y.z where x is 1-3, y is 0-4, and z is 0-9
  12  
  13      Returns:
  14          str: A randomly generated user agent string.
  15      """
  16      lynx_version = f"Lynx/{random.randint(2, 3)}.{random.randint(8, 9)}.{random.randint(0, 2)}"
  17      libwww_version = f"libwww-FM/{random.randint(2, 3)}.{random.randint(13, 15)}"
  18      ssl_mm_version = f"SSL-MM/{random.randint(1, 2)}.{random.randint(3, 5)}"
  19      openssl_version = f"OpenSSL/{random.randint(1, 3)}.{random.randint(0, 4)}.{random.randint(0, 9)}"
  20      return f"{lynx_version} {libwww_version} {ssl_mm_version} {openssl_version}"