serpapi / serpapi-python

an official Python client library for SerpApi.
https://pypi.org/project/serpapi/
MIT License
46 stars 4 forks source link

re-write of python client #4

Closed kennethreitz closed 11 months ago

kennethreitz commented 11 months ago

Hello,

I decided to take a shot at implementing a new Python client based on this codebase, and I'm fairly happy with the results. While still a work in progress, if we can come to an agreement, I think this is a good time to merge my kr-improvements branch into the master branch (perhaps dev is better?).

Documentation has been uploaded to Read the Docs:

https://serpapi-python.readthedocs.io/en/latest/

This is a bit of a different approach than the one that was being taken.

hartator commented 11 months ago

@kennethreitz

Do you think we can also add manual Dict splashing (like adding an if type(params) is dict then doing the same logic) for making things even simpler and more backward compatible?

The following 3 calls are equivalent:

>>> s = serpapi.search(q="Coffee", location="Austin, Texas, United States")

>>> params = {"q": "Coffee", "location": "Austin, Texas, United States"}
>>> s = serpapi.search(**params)
>>> s = serpapi.search(params)

Couple of SerpAPI -> SerpApicase typos.

@ritu1337 Can you do a proper review as your Python is way better than mine? Thank you.

kennethreitz commented 11 months ago

@hartator I experimented with that, but didn't find an elegant solution. Something else is coming to mind now, though. I'll see what I can do.

kennethreitz commented 11 months ago

Thanks again for the feedback, @hartator. Great suggestion. Found a good solution.

kennethreitz commented 11 months ago

Follow-up PR is here: https://github.com/serpapi/serpapi-python/pull/5