Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

image from wikipedia module in python

import wikipedia
import requests
import json

WIKI_REQUEST = 'http://en.wikipedia.org/w/api.php?action=query&prop=pageimages&format=json&piprop=original&titles='

def get_wiki_image(search_term):
    try:
        result = wikipedia.search(search_term, results = 1)
        wikipedia.set_lang('en')
        wkpage = wikipedia.WikipediaPage(title = result[0])
        title = wkpage.title
        response  = requests.get(WIKI_REQUEST+title)
        json_data = json.loads(response.text)
        img_link = list(json_data['query']['pages'].values())[0]['original']['source']
        return img_link        
    except:
        return 0

wiki_image = get_wiki_image('Paris City')
Comment

PREVIOUS NEXT
Code Example
Python :: download stopwords nltk 
Python :: python discord bot wait for response 
Python :: one matrix with np 
Python :: python primera letra mayuscula 
Python :: replace column values pandas 
Python :: ImportError: No module named _tkinter, please install the python-tk package 
Python :: python get date next week 
Python :: rename one dataframe column python 
Python :: TypeError: Unicode-objects must be encoded before hashing 
Python :: convert string to operator python 
Python :: how to do processing on html file using python 
Python :: programe to check if a is divisible 
Python :: os.walk python 
Python :: python plot jpg image 
Python :: python yyyymmdd 
Python :: server error 500 heroku django 
Python :: tkinter maximize window 
Python :: python request post with json with headers 
Python :: how to find word in file python 
Python :: check if a value in dataframe is nan 
Python :: python json parse 
Python :: flip specific bit python 
Python :: python scratch cloud variabelen 
Python :: pandas rename single column 
Python :: python get city name from IP 
Python :: what is r strip function in python 
Python :: how to install cuda in anaconda 
Python :: sqlalchemy delete by id 
Python :: adaptive thresholding python 
Python :: list of characters python 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =