Using Facebook API to find the exact string

I want to use the Facebook API to find exact matches of pages with "My String".

I tried https://graph.facebook.com/search?q=%22My%20String%22&type=page - but it returns pages that match either "String" or "My".

How to create a search query that returns only exact matches with the quoted string?

+6
source share
2 answers

You cannot currently. It is placed on the list.

So you have to wrap the request in Python:

import requests query = 'My String' r = requests.get('https://graph.facebook.com/search?q=%s&type=page' % query) result = r.json result['data'] = [ item for item in result['data'] if query.lower() in item['name'].lower() ] print [ item['name'] for item in result['data'] ] 

Now you have only exact matches.

+6
source

try using Unicode, U + 0200 is a space, so combine "My", U + 0200 and "String". There is no clue if this works.

-1
source

Source: https://habr.com/ru/post/920817/


All Articles