
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
This is the official Python client for the ExportComments API v3, designed to facilitate the integration of advanced language processing capabilities into Python applications. Utilize this client to efficiently build and manage machine learning models for natural language processing directly from your Python environment.
To integrate the ExportComments library into your project, you can easily install it using pip:
pip install exportcomments
Alternatively, if you prefer to install from source or want to contribute to the project, clone the repository and install it manually:
git clone https://github.com/exportcomments/exportcomments-python.git
cd exportcomments-python
pip install -r requirements.txt
python setup.py install
To begin utilizing the ExportComments API, you must first instantiate the ExportComments client with your API key, which is available on your ExportComments account.
from exportcomments import ExportComments
# Initialize the client with your API key
ex = ExportComments('<YOUR API TOKEN HERE>')
Start an export process by submitting a URL to the API. This places the URL in the processing queue. Please note, the queue is limited to 5 concurrent requests.
response = ex.jobs.create(
url='https://www.instagram.com/p/1234567',
options={'replies': True, 'limit': 100}
)
To monitor the status of your export, retrieve the GUID from the initial response and query the export's status.
guid = response.body['guid']
response = ex.jobs.check(guid=guid)
The status of the export can be checked as follows, with potential statuses including "queueing", "error", "done", or "progress":
status = response.body['status']
You can list your existing jobs with pagination:
response = ex.jobs.list(page=1, limit=10)
jobs = response.body
The new API supports various options that can be passed when creating a job:
response = ex.jobs.create(
url='https://www.instagram.com/p/1234567',
options={
'replies': True,
'limit': 500,
'minTimestamp': 1622505600,
'maxTimestamp': 1625097600,
'vpn': 'Norway',
'cookies': {
'sessionid': 'your_session_id'
}
}
)
For backward compatibility, you can still use ex.exports
which will work the same as ex.jobs
:
# This still works for backward compatibility
response = ex.exports.create(
url='https://www.instagram.com/p/1234567',
options={'replies': True}
)
The API might raise exceptions during endpoint calls. Below is an example of how to catch and handle these exceptions:
from exportcomments.exceptions import ExportCommentsException
try:
response = ex.jobs.create(
url='https://www.instagram.com/p/1234567',
options={'replies': True}
)
except ExportCommentsException as e:
# Handles all exceptions derived from ExportCommentsException
print(e)
The following table outlines the available exceptions and their descriptions:
Exception Class | Description |
---|---|
ExportCommentsException | The base class for all exceptions listed below. |
RequestParamsError | Indicates an invalid parameter was sent. Check the message or response object for details. |
AuthenticationError | Occurs when authentication fails, typically due to an invalid API token. |
ForbiddenError | Indicates insufficient permissions for the requested action on the specified resource. |
PlanRateLimitError | Triggered by too many requests in a minute, according to your subscription plan's limits. |
ConcurrencyRateLimitError | Triggered by too many requests in a second, indicating a rate limit on concurrent requests. |
You can download the resulting Excel file by using requests.get. Here's a good example:
import requests
import pkg_resources
# download_link is retrieved from the .check method
download_link = response.body['download_link']
# Set headers for download
headers = {
'X-AUTH-TOKEN': "Your API Token",
'Content-Type': 'application/json',
'User-Agent': 'python-sdk-{}'.format(pkg_resources.get_distribution('exportcomments').version),
}
# Get the excel
response = requests.get(download_link, headers=headers)
# Handle the excel if it is available
if response.status_code == 200:
# Create an excel and save it
with open("result.xlsx", "wb") as output:
output.write(response.content)
print(f"[SUCCESSFUL DOWNLOAD] File Downloaded: {download_link}")
else:
print(f"[FAILED TO DOWNLOAD] Status Code: {response.status_code}")
If you want to contribute to this project, install the development dependencies:
pip install -r requirements.txt
Run tests:
pytest
Here's a comprehensive example demonstrating a typical workflow when only using 1 URL:
import requests
import pkg_resources
from exportcomments import ExportComments, ExportCommentsException
import time
import sys
ex = ExportComments('<YOUR API TOKEN HERE>')
def get_response(guid):
while True:
response = ex.jobs.check(guid=guid)
status = response.body['status']
if status == 'done':
break
elif status == 'error':
print("Error generating your file.")
sys.exit()
time.sleep(20)
download_link = response.body['download_link']
headers = {
'X-AUTH-TOKEN': "Your API Token",
'Content-Type': 'application/json',
'User-Agent': 'python-sdk-{}'.format(pkg_resources.get_distribution('exportcomments').version),
}
response = requests.get(download_link, headers=headers)
if response.status_code == 200:
with open("result.xlsx", "wb") as output:
output.write(response.content)
print(f"[SUCCESSFUL DOWNLOAD] File Downloaded: {download_link}")
else:
print(f"[FAILED TO DOWNLOAD] Status Code: {response.status_code}")
if __name__ == '__main__':
try:
response = ex.jobs.create(
url='https://www.instagram.com/p/1234567',
options={'replies': True, 'limit': 100}
)
except ExportCommentsException as e:
print(e)
sys.exit()
guid = response.body['guid']
get_response(guid)
This version (2.0.0) introduces breaking changes to support API v3:
ex.jobs
instead of ex.exports
(backward compatibility maintained)create()
method now uses an options
parameter instead of individual parameters/api/v3/
endpointsFor more information about the API, visit ExportComments API Documentation.
FAQs
Official Python client for the ExportComments API v3
We found that exportcomments demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.