title: Wikipedia Mediawiki API get Pageid from URL
body: <p>I have a set of full urls like</p>
  
  <pre><code>http://en.wikipedia.org/wiki/Episkopi_Bay
  http://en.wikipedia.org/wiki/Monte_Lauro
  http://en.wikipedia.org/wiki/Lampedusa
  http://en.wikipedia.org/wiki/Himera
  http://en.wikipedia.org/wiki/Lago_Cecita
  http://en.wikipedia.org/wiki/Aspromonte
  </code></pre>
  
  <p>I want to find <strong><em>wikipedia pageids</em></strong> for these URLS. I have used the Mediawiki API before but I cant figure out how I may do this.</p>
  
  <p>I have tried extracting the page title from the URLs by taking a substring of lastindexof("/") and the last character and then querying the API to get pageid. </p>
  
  <pre><code>http://en.wikipedia.org/wiki/Episkopi_Bay --&gt; Episkopi_Bay
  http://en.wikipedia.org/wiki/Monte_Lauro --&gt; Monte_Lauro
  http://en.wikipedia.org/wiki/Lampedusa -- &gt; Lampedusa
  http://en.wikipedia.org/wiki/Himera --&gt; Himera
  http://en.wikipedia.org/wiki/Lago_Cecita --&gt; Lago_Cecita
  http://en.wikipedia.org/wiki/Aspromonte --&gt; Aspromonte
  </code></pre>
  
  <p>But the problem is that some of my links might be redirects and hence the substring might not always be the title of the page. </p>
  
  <p><strong>TL;DR : How can I find the pageid of a wikipedia page from a URL ?</strong></p>