Created
February 15, 2024 18:52
-
-
Save Xnuvers007/f63267b872e4beb63be5fb377603b4e0 to your computer and use it in GitHub Desktop.
Real Count & Quick Count 2024 Indonesia
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 fetch from 'node-fetch'; | |
fetch('https://quickcount.kumparan.com/v1/election-result', { | |
method: 'GET', | |
headers: { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0', | |
'Accept': 'application/json, text/plain, */*' | |
} | |
}) | |
.then(response => response.json()) | |
.then(data => { | |
console.log("Quick Count Data:"); | |
for (var i = 0; i < data.quick_count.length; i++) { | |
console.log(data.quick_count[i].survey_institution + '\nTotal: ' + data.quick_count[i].total_votes_cast + '\nUpdate: ' + data.quick_count[i].updated_at); | |
for (var j = 0; j < data.quick_count[i].candidate_vote_acquisitions.length; j++) { | |
console.log(data.quick_count[i].candidate_vote_acquisitions[j].number + " " + data.quick_count[i].candidate_vote_acquisitions[j].name + " " + data.quick_count[i].candidate_vote_acquisitions[j].vote_count + " " + data.quick_count[i].candidate_vote_acquisitions[j].image_url); | |
} | |
console.log("\n"); | |
} | |
console.log("\nReal Count Data:"); | |
const realCount = data.real_count; | |
console.log(`${realCount.survey_institution}\nTotal: ${realCount.total_votes_cast}\nUpdate: ${realCount.updated_at}`); | |
realCount.candidate_vote_acquisitions.forEach(candidate => { | |
console.log(`${candidate.number} ${candidate.name} ${candidate.vote_count} ${candidate.image_url}`); | |
}); | |
}) | |
.catch(error => console.error('Fetch Error:', error)); |
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 | |
url = 'https://quickcount.kumparan.com/v1/election-result' | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0', | |
'Accept': 'application/json, text/plain, */*' | |
} | |
response = requests.get(url, headers=headers) | |
if response.status_code == 200: | |
data = response.json() | |
print("Quick Count Data:") | |
for result in data['quick_count']: | |
print(f"{result['survey_institution']}\nTotal: {result['total_votes_cast']}\nUpdate: {result['updated_at']}") | |
for candidate in result['candidate_vote_acquisitions']: | |
print(f"{candidate['number']} {candidate['name']} {candidate['vote_count']} {candidate['image_url']}") | |
print() | |
print("\nReal Count Data:") | |
real_count = data['real_count'] | |
print(f"{real_count['survey_institution']}\nTotal: {real_count['total_votes_cast']}\nUpdate: {real_count['updated_at']}") | |
for candidate in real_count['candidate_vote_acquisitions']: | |
print(f"{candidate['number']} {candidate['name']} {candidate['vote_count']} {candidate['image_url']}") | |
else: | |
print(f"Error: {response.status_code}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment