Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/galloclaudio/mega-search-links/llms.txt

Use this file to discover all available pages before exploring further.

What is a user-agent?

A user-agent is an HTTP header that identifies your application to the server. It tells the server what type of client is making the request (browser, bot, script, etc.). Many APIs and web services use this information to:
  • Track usage patterns and analytics
  • Apply rate limiting policies
  • Serve different content based on the client type
  • Block or allow specific clients

Why customize the user-agent?

Customizing your user-agent is important for:
  • Identification: Clearly identify your application to server administrators
  • Compliance: Some APIs require specific user-agent formats
  • Debugging: Easily track requests from your application in server logs
  • Courtesy: Follow best practices by properly identifying your bot or application

How URLFetcher uses the user-agent

The URLFetcher class accepts a user_agent parameter during initialization and stores it in the headers dictionary:
main.py:4-13
class URLFetcher:
    def __init__(self, base_url, user_agent):
        """
        Initializes the URLFetcher with a base URL and user-agent.

        Parameters:
        base_url (str): The base URL for the API.
        user_agent (str): The user-agent string to be used for the requests.
        """
        self.base_url = base_url
        self.headers = {'User-Agent': user_agent}
This header is then used in all HTTP requests made by the fetch_urls method:
main.py:30
response = requests.get(url, headers=self.headers)

Basic usage

1

Initialize URLFetcher with custom user-agent

from main import URLFetcher

base_url = "https://meawfy.com/internal/api/results.json"
user_agent = "MyCustomUserAgent/1.0"

fetcher = URLFetcher(base_url, user_agent)
2

Make requests with your custom user-agent

urls = fetcher.fetch_urls("example_query")
All requests will now include your custom user-agent header.

User-agent string examples

Identify your application with version and contact info:
user_agent = "MeawfyBot/2.0 (+https://example.com/bot-info)"
fetcher = URLFetcher(base_url, user_agent)
This format is recommended for bots and automated tools.

Best practices

Always include contact information in your user-agent string. This allows server administrators to reach you if there are issues with your requests.
AppName/Version (Platform; +ContactURL)
Example:
user_agent = "MegaSearchClient/1.0 (Python; +https://github.com/yourname/your-project)"

When to use different user-agents

  • Custom application string: Best for most use cases, clearly identifies your app
  • Browser string: Only when the API specifically requires it or serves different content to browsers
  • Descriptive bot string: When running automated tasks, crawlers, or data collection
  • Generic string: Avoid this - always be specific about your application

Dynamic user-agent configuration

You can make your user-agent configurable for different environments:
import os
from main import URLFetcher

# Load from environment variable
user_agent = os.getenv('MEAWFY_USER_AGENT', 'MegaSearchClient/1.0')

# Or use different user-agents for production vs development
if os.getenv('ENV') == 'production':
    user_agent = "MegaSearchClient/1.0 (Production; +https://example.com)"
else:
    user_agent = "MegaSearchClient/1.0 (Development; testing@example.com)"

fetcher = URLFetcher(
    "https://meawfy.com/internal/api/results.json",
    user_agent
)

Rotating user-agents

For applications that need to rotate user-agents:
from main import URLFetcher
import random

user_agents = [
    "MegaSearchClient/1.0 (Linux; +https://example.com)",
    "MegaSearchClient/1.0 (Windows; +https://example.com)",
    "MegaSearchClient/1.0 (macOS; +https://example.com)",
]

base_url = "https://meawfy.com/internal/api/results.json"

# Create new fetcher with random user-agent for each session
for query in ["movies", "games", "courses"]:
    user_agent = random.choice(user_agents)
    fetcher = URLFetcher(base_url, user_agent)
    urls = fetcher.fetch_urls(query)
    print(f"Found {len(urls)} URLs for {query}")
Rotating user-agents should only be done when necessary and in compliance with the API’s terms of service. Excessive rotation may be seen as an attempt to evade detection.