AlienVault-OTX / OTX-Python-SDK

The Python SDK for AlienVault OTX
Other
358 stars 162 forks source link

Issue retrieving single pulse #14

Closed rspitler-alien closed 8 years ago

rspitler-alien commented 8 years ago

Making public record for issue (RS)

trying to write python script, got the following code:

initialize

from OTXv2 import OTXv2 from pandas.io.json import json_normalize from datetime import datetime, timedelta otx = OTXv2(my key) otx.get("http://otx.alienvault.com/pulse/56e96f904637f2285c708f55")

keep getting the following error, no mattar how I format the url:

ValueError Traceback (most recent call last)

in () ----> 1 otx.get("/pulse/56e71ff467db8c4088b184fe") \OTX-Python-SDK\OTXv2.pyc in get(self, url) 66 response = None 67 try: ---> 68 response = request.open(url) 69 except URLError as e: 70 if e.code == 403: C:\Anaconda\lib\urllib2.pyc in open(self, fullurl, data, timeout) 421 422 req.timeout = timeout --> 423 protocol = req.get_type() 424 425 # pre-process request C:\Anaconda\lib\urllib2.pyc in get_type(self) 283 self.type, self.__r_type = splittype(self.__original) 284 if self.type is None: --> 285 raise ValueError, "unknown url type: %s" % self.__original 286 return self.type 287 ## ValueError: unknown url type: /pulse/56e96f904637f2285c708f55 I;m trying to download a specific pulse, how can I do it if not this way? Thank you
rspitler-alien commented 8 years ago

the otx.get() function is an internal function and should not be used in this way. The best way to do what you want in this case is to do the following

otx = OTXv2(my key) for pulse in otx.getall_iter(): pulse_id = pulse['id'] if pulse_id == "56e96f904637f2285c708f55": return pulse