'How to send request to Phish Tank Api?
I am trying to send a request to phish tank and get an answer in JSON format using Python. However, I'm doing something wrong and I have no clue how to fix that. I tried to put the URI after the request URL in the headers but it did not work out.
Does anybody know how to do it properly?
import requests
import json
from keys import phish_tank_key
headers = {
'format': 'json',
'app_key': phish_tank_key,
}
def get_url_with_ip(URI):
"""Returns url with URI needed for request"""
url = "http://checkurl.phishtank.com/checkurl/"
url += URI
return url
def send_the_request_to_phish_tank(url, headers):
"""This function sends a request."""
print(url)
response = requests.request("POST", url=url, headers=headers)
return response
new_check = 'https://atsdddatffsd.weebly.com/'
url = get_url_with_ip(new_check)
r = send_the_request_to_phish_tank(url, headers)
print(r.text)
Many thanks
Solution 1:[1]
A simple implementation
# Python implementation
endpoint = "https://checkurl.phishtank.com/checkurl/"
url = "http://www.travelswitchfly.com/"
response = requests.post(endpoint, data={"url": url, "format": "json"})
Checkout detailed explanation here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kaushik Kakdey |
