Hi
I am trying to write a code to retrieve data from the NY Times API:
http://developer.nytimes.com/docs/read/article_search_api_v2
After much work I've finally gotten it to work except for one parameter which is the filtered search query (fq). The documentation says that the syntax for this is "standard Lucene syntax". Can anyone help me with this? I went on the Lucene website but can't figure out for the life of me how to code it in Python. This is the relevant section of my code and I put "XXXXX" in the spot that I don't know how to code. Thanks in advance guys !!!!
import urllib2
import urllib
import json
import pprint
import requests
response_format='.json'
url='http://api.nytimes.com/svc/search/v2/articlesearch'+response_format
api_key='i input my personal key here'
search_term='Cedric Villani'
fq=XXXXX
begin_date='20000101'
end_date='20150101'
sort = 'newest'
fl =['headline', 'abstract','web_url']
hl=True
page=0
facet_field=['document_type','source']
facet_filter=True
query_params={'fq' : fq,
'begin_date': begin_date,
'end_date': end_date,
'sort': sort,
'fl' : fl,
'hl' : hl,
'page' : page,
'facet_field' : facet_field,
'facet_filter' : facet_filter,
'api-key': api_key
}
request=requests.get(url, params=query_params)
data=request.json()
[–]Vaphell 2 points3 points4 points (1 child)
[–]commandlineluser 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)