Created
March 24, 2023 19:28
-
-
Save ridgewell/72958c08aa04d8c79b94aec36692852f to your computer and use it in GitHub Desktop.
Extract Mysterium VPN nodes to a CSV File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import csv | |
# Make a request to the API | |
response = requests.get('https://discovery.mysterium.network/api/v3/proposals') | |
# Extract the JSON data | |
data = response.json() | |
# Create a CSV file and write the data to it | |
with open('mysterium_proposals.csv', 'w', newline='') as csvfile: | |
writer = csv.writer(csvfile) | |
# Write the headers | |
writer.writerow(['id', 'format', 'compatibility', 'provider_id', 'service_type', 'continent', 'country', 'region', 'city', 'asn', 'isp', 'ip_type', 'quality', 'latency', 'bandwidth', 'uptime']) | |
# Write each proposal as a row in the CSV file | |
for proposal in data: | |
quality = proposal['quality'] | |
writer.writerow([ | |
proposal['id'], | |
proposal['format'], | |
proposal['compatibility'], | |
proposal['provider_id'], | |
proposal['service_type'], | |
proposal['location'].get('continent'), | |
proposal['location'].get('country'), | |
proposal['location'].get('region'), | |
proposal['location'].get('city'), | |
proposal['location'].get('asn'), | |
proposal['location'].get('isp'), | |
proposal['location'].get('ip_type'), | |
quality.get('quality'), | |
quality.get('latency'), | |
quality.get('bandwidth'), | |
quality.get('uptime') | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment