salvoventura / pypexels

An open source Python wrapper for the Pexels REST API https://www.pexels.com/api/.
MIT License
73 stars 15 forks source link

query search with whitespace gives different results than website search #8

Open robbiedood opened 4 years ago

robbiedood commented 4 years ago

Dear salvoventura,

I found that a video search query contains a white space, such as 'dancing couple', cause issue. The api search result is different than manually search from pexels website.

I've tried 'dancing+couple' and 'dancing%20couple', but still can not align the search results.

Maybe I miss something, so hope to hear your expertise on the issue.

Thanks.

salvoventura commented 4 years ago

Hi, thanks for reporting this. I can't be sure, but from all I see, you are doing the right thing, and so is the library.

The way I checked for that is the following:

  1. when you do a search on the pexels website, for example "dancing couple" you are redirected to this URL: https://www.pexels.com/search/videos/dancing%20couple/ It doesn't matter whether your search "dancing couple" or "dancing+couple" you are redirected to the same URL.
  1. with the API, the same happens: if you look at the JSON response from the API, you see something like this:

{ "page": 1, "per_page": 15, "total_results": 1003, "url": "https://www.pexels.com/search/videos/dancing couple/", "videos": [

Notice the url, which matches the one from the website search.

So, my guess is that it's more of a sorting issue than different results, especially given that the pexels page has infinite scrolling.

Sorry if this doesn't help you solve your issue, and I hope it gives you a bit more context. If this is all, please close the issue with your next comment.

Cheers!