### Install Setuptools on Unix (wget) Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/setuptools-28.8.0.dist-info/DESCRIPTION.rst Download the ez_setup.py script using wget and execute it with Python. Use sudo for system-wide installation or --user for a user-local installation. This method may require bypassing certificate checks on older systems. ```bash wget https://bootstrap.pypa.io/ez_setup.py -O - | python ``` ```bash wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python ``` ```bash wget https://bootstrap.pypa.io/ez_setup.py -O - | python - --user ``` ```bash wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py python ez_setup.py --insecure ``` -------------------------------- ### Advanced Setuptools Installation Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/setuptools-28.8.0.dist-info/DESCRIPTION.rst For custom installations, download and extract the setuptools source tarball from PyPI. Then, run the setup.py script with desired distutils and setuptools options, such as specifying a custom installation prefix. ```bash setuptools-x.x$ python setup.py install --prefix=/opt/setuptools ``` -------------------------------- ### Install Certifi using pip Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/certifi-2018.4.16.dist-info/DESCRIPTION.rst Install the certifi package using pip. This command fetches and installs the latest version from PyPI. ```bash $ pip install certifi ``` -------------------------------- ### Install urllib3 from Source Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/urllib3-1.23.dist-info/DESCRIPTION.rst Clones the urllib3 repository from GitHub and installs it using setup.py. ```bash git clone git://github.com/urllib3/urllib3.git python setup.py install ``` -------------------------------- ### Install urllib3 using pip Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/urllib3-1.23.dist-info/DESCRIPTION.rst Installs the urllib3 library using the pip package installer. ```bash pip install urllib3 ``` -------------------------------- ### Install Setuptools on Unix (curl) Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/setuptools-28.8.0.dist-info/DESCRIPTION.rst Use curl to download the ez_setup.py script and pipe it to the Python interpreter for installation. This is an alternative to using wget. ```bash curl https://bootstrap.pypa.io/ez_setup.py -o - | python ``` -------------------------------- ### Install Requests with Pipenv Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/requests-2.19.1.dist-info/DESCRIPTION.rst Shows the command to install the Requests library using Pipenv. Ensure Pipenv is installed and configured for your project. ```bash $ pipenv install requests ✨🍰✨ ``` -------------------------------- ### Get Certifi CA Bundle Path Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/certifi-2018.4.16.dist-info/DESCRIPTION.rst Import the certifi library and use the where() function to get the absolute path to the installed CA certificate bundle. ```python import certifi certifi.where() ``` -------------------------------- ### Install Chardet using pip Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/chardet-3.0.4.dist-info/DESCRIPTION.rst Install the chardet library from PyPI using pip. This is the standard method for adding the package to your Python environment. ```bash pip install chardet ``` -------------------------------- ### Install Setuptools on Windows (PowerShell) Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/setuptools-28.8.0.dist-info/DESCRIPTION.rst Use this command in PowerShell to download and run the setuptools bootstrap script. Ensure you have administrative privileges or use the --user flag for a user-local installation. ```powershell (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python - ``` ```powershell (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python - --user ``` ```powershell (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | py -3 - ``` -------------------------------- ### Basic GET Request with Requests Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/requests-2.19.1.dist-info/DESCRIPTION.rst Demonstrates a simple GET request to the GitHub API, including authentication and inspecting the response. Use this for fetching data from web APIs. ```python >>> r = requests.get('https://api.github.com/user', auth=('user', 'pass')) >>> r.status_code 200 >>> r.headers['content-type'] 'application/json; charset=utf8' >>> r.encoding 'utf-8' >>> r.text u'{"type":"User"...' >>> r.json() {u'disk_usage': 368627, u'private_gists': 484, ...} ``` -------------------------------- ### Basic HTTP Request with urllib3 Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/urllib3-1.23.dist-info/DESCRIPTION.rst Demonstrates a basic GET request using PoolManager to fetch data from a URL and access the response status and content. ```python import urllib3 http = urllib3.PoolManager() r = http.request('GET', 'http://httpbin.org/robots.txt') r.status r.data ``` -------------------------------- ### Get User Search Query Info Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Interactively prompts the user for a text query and optional birth date. Invalid or empty date inputs default to 0. ```python def get_query_info(): text = input("Enter your text query (the name and the last name) here: ") print("Now input the date of the birth") try: day = int(input("Day: ")) except ValueError: day = 0 try: month = int(input("Month: ")) except ValueError: month = 0 try: year = int(input("Year: ")) except ValueError: year = 0 return text, day, month, year # Usage text_query, day_of_birth, month_of_birth, year_of_birth = get_query_info() # Input example: # Enter your text query: Ivan Petrov # Day: 15 # Month: 3 # Year: 1990 # Returns: ("Ivan Petrov", 15, 3, 1990) ``` -------------------------------- ### Get Odnoklassniki User Friends Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Retrieves a list of friend IDs for a given user. Handles potential API errors and processes large friend lists in batches. ```python ok_object = Odnoklassniki(CLIENT_KEY, SECRET_KEY, ACCESS_TOKEN) try: user_friends_ids = ok_object.friends.get(fid=id_input) except OdnoklassnikiError: user_friends_ids = [] finally: print("Found", len(user_friends_ids), "friends") if user_friends_ids: while len(user_friends_ids) > 100: work_with_friends_list(fields_parameter, ok_object) user_friends_ids = user_friends_ids[100:] else: work_with_friends_list(fields_parameter, ok_object) ``` -------------------------------- ### Print Formatted User Records Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Iterates through a list of user dictionaries from the `search.quick` API response and prints a normalized dictionary for each user. ```python # search.py def print_users(users_list): for user in users_list: print({ "id": user["uid"], "name": user["first_name"], "last_name": user["last_name"], "birthday": user["birthday"], "city": user["location"]["city"] }) # Sample output for one user: ``` -------------------------------- ### Build API Fields Selection String Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Generates a comma-separated `fields` parameter string for API methods like `search.quick` and `users.getInfo`. Each field is lowercased and prefixed with `user.`. ```python # shared by both search.py and friends.py def get_fields_parameter(fields_names): fields_string = ", ".join( ["user." + field.lower() for field in fields_names] ) return fields_string FIELDS_OF_RESULTS = ( "BIRTHDAY", "FIRST_NAME", "LAST_NAME", "LOCATION", "UID", ) fields_parameter = get_fields_parameter(FIELDS_OF_RESULTS) # Returns: "user.birthday, user.first_name, user.last_name, user.location, user.uid" ``` -------------------------------- ### Fetch and Print Batch of Friends Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Fetches a batch of up to 100 friends using their IDs and prints the detailed profile information for each. Relies on an external list of friend IDs and API credentials. ```python # friends.py def work_with_friends_list(fields, ok): friends = ok.users.getInfo( uids=", ".join(user_friends_ids[0:100]), fields=fields ) print_friends(friends) # Usage context (from main block): # fields_parameter = "user.birthday, user.first_name, user.last_name, user.location, user.uid" # ok_object = Odnoklassniki(CLIENT_KEY, SECRET_KEY, ACCESS_TOKEN) # user_friends_ids = ["111", "222", "333", ...] # populated via friends.get work_with_friends_list(fields_parameter, ok_object) # Output: # {'id': '111', 'name': 'Alexei', 'last_name': 'Ivanov', 'birthday': '1988-11-22', 'city': 'Kazan'} # {'id': '222', 'name': 'Maria', 'last_name': 'Kuznetsova', 'birthday': '1995-05-30', 'city': 'Novosibirsk'} ``` -------------------------------- ### Build API Filter String for User Search Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Constructs the JSON-formatted `filters` parameter for the `search.quick` API call. Conditionally adds birth date fields if they are non-zero. ```python def get_filters_parameter(day, month, year): filters = [{"type": "user"}] filters[0].update({ key: value for key, value in zip( ("birthDay", "birthMonth", "birthYear"), (day, month, year) ) if value }) filters_string = str(filters).replace("'", '"') return filters_string # Full birth date provided filters_parameter = get_filters_parameter(15, 3, 1990) # Returns: '[{"type": "user", "birthDay": 15, "birthMonth": 3, "birthYear": 1990}]' # Only year provided (day=0, month=0 are excluded) filters_parameter = get_filters_parameter(0, 0, 1990) # Returns: '[{"type": "user", "birthYear": 1990}]' # No birth date (all zeros) filters_parameter = get_filters_parameter(0, 0, 0) # Returns: '[{"type": "user"}]' ``` -------------------------------- ### Detect Encoding of Files using chardetect Source: https://github.com/tolber01/odnoklassniki-users-and-friends-parser/blob/master/venv/Lib/site-packages/chardet-3.0.4.dist-info/DESCRIPTION.rst Use the chardetect command-line script to determine the character encoding of one or more files. The output includes the filename, detected encoding, and confidence level. ```bash % chardetect somefile someotherfile somefile: windows-1252 with confidence 0.5 someotherfile: ascii with confidence 1.0 ``` -------------------------------- ### Format and Print Friend Records Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Iterates through a list of user-info dictionaries and prints a normalized dictionary for each friend. This function is functionally identical to `print_users` but defined separately. ```python # friends.py def print_friends(friends_list): for friend in friends_list: print({ "id": friend["uid"], "name": friend["first_name"], "last_name": friend["last_name"], "birthday": friend["birthday"], "city": friend["location"]["city"] }) ``` -------------------------------- ### Paginated User Search with Odnoklassniki API Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Searches users using the Odnoklassniki API with interactive query parameters and paginates through results using an anchor. Requires API credentials and handles potential errors. ```python # search.py – full main block from odnoklassniki import Odnoklassniki CLIENT_KEY = "your_client_key" SECRET_KEY = "your_secret_key" ACCESS_TOKEN = "your_access_token" FIELDS_OF_RESULTS = ("BIRTHDAY", "FIRST_NAME", "LAST_NAME", "LOCATION", "UID") MAX_NUMBER_OF_RESULTS = 100 TYPE_OF_RESULTS = "USER" text_query, day_of_birth, month_of_birth, year_of_birth = get_query_info() # Example input: "Ivan Petrov", day=15, month=3, year=1990 filters_parameter = get_filters_parameter(day_of_birth, month_of_birth, year_of_birth) fields_parameter = get_fields_parameter(FIELDS_OF_RESULTS) ok_object = Odnoklassniki(CLIENT_KEY, SECRET_KEY, ACCESS_TOKEN) has_more_users = True first_iteration = True anchor_parameter = "" while has_more_users: response_object = ok_object.search.quick( query=text_query, types=TYPE_OF_RESULTS, fields=fields_parameter, filters=filters_parameter, anchor=anchor_parameter, count=MAX_NUMBER_OF_RESULTS ) try: if first_iteration: print("Found users:", response_object["totalCount"]) # Output: Found users: 42 first_iteration = False users_objects_list = response_object["entities"]["users"] has_more_users = response_object["has_more"] anchor_parameter = response_object["anchor"] except KeyError: break else: print_users(users_objects_list) # Output per user: # {'id': '123456789', 'name': 'Ivan', 'last_name': 'Petrov', # 'birthday': '1990-03-15', 'city': 'Moscow'} ``` -------------------------------- ### Fetch All Friends of a User Source: https://context7.com/tolber01/odnoklassniki-users-and-friends-parser/llms.txt Retrieves the complete friends list for a given user ID from the Odnoklassniki API, handling potential errors for private or empty lists. Fetches detailed profile information in batches. ```python # friends.py – full main block from odnoklassniki import Odnoklassniki, OdnoklassnikiError CLIENT_KEY = "your_client_key" SECRET_KEY = "your_secret_key" ACCESS_TOKEN = "your_access_token" FIELDS_OF_RESULTS = ("BIRTHDAY", "FIRST_NAME", "LAST_NAME", "LOCATION", "UID") fields_parameter = get_fields_parameter(FIELDS_OF_RESULTS) id_input = input("Enter user's id here: ") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.