space
This commit is contained in:
parent
388f33ebb6
commit
665a4038b2
1 changed files with 3 additions and 3 deletions
|
@ -17,7 +17,7 @@ def get_id(url):
|
||||||
|
|
||||||
def get_url(id=None, imdb=None, allmovie=None):
|
def get_url(id=None, imdb=None, allmovie=None):
|
||||||
if imdb:
|
if imdb:
|
||||||
query = '"%s"'% imdb
|
query = '"%s"' % imdb
|
||||||
result = find(query)
|
result = find(query)
|
||||||
if result:
|
if result:
|
||||||
url = result[0][1]
|
url = result[0][1]
|
||||||
|
@ -26,7 +26,7 @@ def get_url(id=None, imdb=None, allmovie=None):
|
||||||
return url
|
return url
|
||||||
return ""
|
return ""
|
||||||
if allmovie:
|
if allmovie:
|
||||||
query = '"amg_id = 1:%s"'% allmovie
|
query = '"amg_id = 1:%s"' % allmovie
|
||||||
result = find(query)
|
result = find(query)
|
||||||
if result:
|
if result:
|
||||||
url = result[0][1]
|
url = result[0][1]
|
||||||
|
@ -140,7 +140,7 @@ def get_allmovie_id(wikipedia_url):
|
||||||
return data.get('amg_id', '')
|
return data.get('amg_id', '')
|
||||||
|
|
||||||
def find(query, max_results=10):
|
def find(query, max_results=10):
|
||||||
query = {'action': 'query', 'list':'search', 'format': 'json',
|
query = {'action': 'query', 'list': 'search', 'format': 'json',
|
||||||
'srlimit': max_results, 'srwhat': 'text', 'srsearch': query.encode('utf-8')}
|
'srlimit': max_results, 'srwhat': 'text', 'srsearch': query.encode('utf-8')}
|
||||||
url = "http://en.wikipedia.org/w/api.php?" + urllib.parse.urlencode(query)
|
url = "http://en.wikipedia.org/w/api.php?" + urllib.parse.urlencode(query)
|
||||||
data = read_url(url)
|
data = read_url(url)
|
||||||
|
|
Loading…
Reference in a new issue