wikipedia-api

CORS header ‘Access-Control-Allow-Origin’ missing from Wikipedia API response [duplicate]

浪子不回头ぞ 提交于 2019-12-11 06:39:23
问题 This question already has an answer here : Does Wikipedia API support CORS or only JSONP available? (1 answer) Closed last year . I'm trying to fetch data from the Wikipedia API with axios in reactJS. This is my get request axios.get('https://en.wikipedia.org/w/api.php?action=opensearch&search=lol&format=json&callback=?') .then((response) => { console.log(response); }) .catch((error)=>{ console.log(error); }); I got this error: Cross-Origin Request Blocked: The Same Origin Policy disallows

Search for a Wikipedia page based on its NRHP refnum

旧时模样 提交于 2019-12-11 06:26:23
问题 I have an application which maintains a table of places registered in the National Registry of Historic places. I'd like to reliably search for one of these places in Wikipedia, given its NRHP refnum . The search I am currently using now looks like this: http://en.wikipedia.org/w/index.php?title=Special:Search&search=refnum+66000539 (I use Python as my language, but I don't think this is especially relevant here. I construct the url, do a urlfetch , and see what comes back.) But this example,

wikipedia API JSON isn't recognized by $.getJSON() method

混江龙づ霸主 提交于 2019-12-11 01:18:59
问题 I know already that this method works for other JSON formatted data but not the wikipedia API JSON output as listed here. Any help would be great: $.getJSON('https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrsearch=starwars', function(data) { $("p").html(JSON.stringify(data)); }); 回答1: Add callback $.getJSON('https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrsearch=starwars&callback=?', function(data) { console.log(data); }); <script

Reach a string behind unknown value in JSON

╄→гoц情女王★ 提交于 2019-12-10 20:53:38
问题 I use Wikipedia's API to get information about a page. The API gives me JSON like this: "query":{ "pages":{ "188791":{ "pageid":188791, "ns":0, "title":"Vanit\u00e9", "langlinks":[ { "lang":"bg", "*":"Vanitas" }, { "lang":"ca", "*":"Vanitas" }, ETC. } } } } You can see the full JSON response. I want to obtain all entries like: { "lang":"ca", "*":"Vanitas" } but the number key ("188791") in the pages object is the problem. I found Find a value within nested json dictionary in python that

Wikipedia query returns error 403

社会主义新天地 提交于 2019-12-10 18:29:02
问题 I'm querying Wikipedia using the following code, but I always get an error (403 forbidden). When I type the exact same url in my browser, however, it works. I've been using the same code before to query other web apis, so I am not sure what's causing the trouble. private static string query(string text) { text = text.Replace(" ", "%20"); string url = "http://en.wikipedia.org/w/api.php?action=opensearch&search=" + text + "&format=json&callback=spellcheck"; WebClient client = new WebClient();

Wikipedia API and SPARQL in a single query

梦想与她 提交于 2019-12-10 16:08:36
问题 I need to search for Wikipedia pages that contain some specific words in their full text . To improve the results I want to limit the results to pages describing entities that are instances of a specific entity. For searching the full text I can use the Wikipedia APIs, using the query action and the search generator . For filtering instances of a given entity I can use the Wikidata APIs and a SPARQL query. Is there a way to execute both operations in a single query that applies both filters?

Link terms on page to Wikipedia articles in pure JavaScript

元气小坏坏 提交于 2019-12-10 14:59:52
问题 While browsing I came across this blog post about using the Wikipedia API from JavaScript, to link a single search term to it's definition. At the end of the blog post the author mentions possible extensions including: A plugin which auto links terms to Wikipedia articles. This fits the bill perfectly for a project requirement I'm working on, but sadly I lack the programming skills to extend the original source code. What I'd like is to have a pure JavaScript snippet I can add to a webpage,

Getting Wikipedia infobox content with JQuery

狂风中的少年 提交于 2019-12-09 12:16:49
问题 I'm looking to use JQuery to pull back contents of the Wikipedia infobox that contains company details. I think that I'm almost there but I just can't get the last step of the way var searchTerm="toyota"; var url="http://en.wikipedia.org/w/api.php?action=parse&format=json&page=" + searchTerm+"&redirects&prop=text&callback=?"; $.getJSON(url,function(data){ wikiHTML = data.parse.text["*"]; $wikiDOM = $(wikiHTML); $("#result").append($wikiDOM.find('.infobox').html()); }); The first part works -

Using Wikipedia's API to fetch results from search query

拈花ヽ惹草 提交于 2019-12-08 19:09:03
问题 I am trying to use Wikipedia's API to make a search query, then append those results to my page. This is what I have so far : "use strict"; $(document).ready(function(){ function searchWikipedia(searchCriteria){ $.getJSON('https://en.wikipedia.org/w/api.php?action=query&format=json&limit=15&callback=?&titles=' + searchCriteria, processResult); } $('#btn').click(function searchCriteria() { var searchCriteria = $("input[name=Wikipedia]").val(); searchWikipedia(searchCriteria); }) function

Concurrent Python Wikipedia Package Requests

浪尽此生 提交于 2019-12-08 07:02:43
问题 I am making a python application which uses the python Wikipedia package to retrieve the body text of 3 different Wikipedia pages. However, I am noticing very slow performance when retrieving the articles one at a time. Is there a method that I can use to retrieve the body text of 3 Wikipedia pages in parallel? 回答1: If you want the 'raw' page you can use any python scraping library such as twisted/scrapy. But, if you are looking for the parsed wiki format you should use pywikibot