2
from fake_useragent import UserAgent
import requests

ua = UserAgent()
header = {'User-Agent':str(ua.chrome)}

d = {"query": "/api/v2/details/ip/", "query_entry": "41.219.127.69"}


r = requests.get("https://talosintelligence.com/sb_api/query_lookup/", 
data = d, headers=header)

When I run the same result from the main site "talosintelligence.com" and look at the network counsel, that exact URL is responds with a JSON file but a get request from python returns None.

Screenshot of page

2
  • 3
    I think it may be using a session cookie to confirm that the query is coming from the form. Commented Aug 15, 2017 at 0:18
  • 2
    There's a cookie callesd talos_website_session. Commented Aug 15, 2017 at 0:19

1 Answer 1

1

I got it to work by setting the referer header..

import requests
sess = requests.session()
ip_addr = "41.219.127.69"
ret = sess.get('https://talosintelligence.com/sb_api/query_lookup', data={"query": "/api/v2/details/ip/", "query_entry": ip_addr, "offset": 0, "order": "ip asc"}, headers={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.31 Safari/537.36', 'referer': 'https://talosintelligence.com/reputation_center/lookup?search=' + ip_addr})
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you!! Just adding "referer" to the header resolved it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.