IntelligenceX / SDK

Public SDK for Intelligence X
https://intelx.io
405 stars 93 forks source link

Enhancement "f" and "l" Parameters of Search API #558

Open cmlh opened 5 months ago

cmlh commented 5 months ago

Transfer Pull Request https://github.com/IntelligenceX/Python/pull/24

Patch from @anhtn512 has been reproduced below:

    def INTEL_EXPORT(self, id, start=1, end=1000, filename="sample"):
        """
        Export all file from search. Use this for direct data download All file in one time.
        id search:
        - Specifies search ID.
        start option:
        - start index of search
        - default: 1
        end option:
        - end index of search
        - default: 1000
        filename option:
        - Specify the name to save the file as (default: sample, extention alway is zip).
        """
        time.sleep(self.API_RATE_LIMIT)
        h = {'x-key': self.API_KEY, 'User-Agent': self.USER_AGENT}
        r = requests.get(f"{self.API_ROOT}/intelligent/search?id={id}&f={start}&l={end}", headers=h, stream=True)
        if r.status_code == 200:
            with open(f"{filename}.zip", "wb") as f:
                f.write(r.content)
                f.close()
            return True
        else:
            return r.status_code
anhtn512 commented 5 months ago

I have created a pull request for it

559