mediawiki-api - links on page & getting fields on those pages - mediawiki

If I have a wikimedia category such as "Category:Google_Art_Project_works_by_Vincent_van_Gogh", is there an API to retrieve a list of the URLs linked to on that page?
I've tried this, but it doesn't return any links: https://en.wikipedia.org/w/api.php?action=query&titles=Category:Google_Art_Project_works_by_Vincent_van_Gogh&prop=links
(If not, I'll parse the html and obtain them that way.)
Once I have all the URLs linked to, is there an API to retrieve some of the information on the page? (Summary/Artist, Title, Date, Dimensions, Current location, Licensing)
I've tried this, but it doesn't seem to have a way to return that information: https://en.wikipedia.org/w/api.php?action=query&titles=File:Irises-Vincent_van_Gogh.jpg&prop=imageinfo&iiprop=url

is there an API to retrieve a list of the URLs linked to on that page?
I guess you're looking for the Categorymembers API which will list the pages in the selected category.
I've tried this, but it doesn't return any links: https://en.wikipedia.org/w/api.php?action=query&titles=Category:Google_Art_Project_works_by_Vincent_van_Gogh&prop=links
First, notice that this is a Wikimedia Commons Category, querying the en.wikipedia.org did return a you a missing page. However, even if you query the right project, you will notice that the category description does indeed not contain any links.
Once I have all the URLs linked to, is there an API to retrieve some of the information on the page?
You can use the categorymembers query as a generator, then specify the usual properties that you want from each page. However, the metadata you seem to be interested in is not available via the API, you need to parse it out of each image description text.
Try https://commons.wikimedia.org/w/api.php?action=query&generator=categorymembers&gcmtitle=Category%3aGoogle_Art_Project_works_by_Vincent_van_Gogh&prop=links|imageinfo|revisions&iiprop=timestamp|user|url|size|mime&rvprop=ids|content&rvgeneratexml

Related

Can I get a version of a Wikipedia page as of specified date?

I am trying to access old version of Wiki pages using data instead of "oldid". Usually to access and a version of a wiki page, I have to use the page id like this https://en.wikipedia.org/w/index.php?title=Main_Page&oldid=969106986, is there a way to access the same page using the date without knowing the ID? If i know for example that there is a version of the page published on "12:44, 23 July 2020‎ "
In addition to the "main" API (called the action API by MediaWiki developers), you can also use the REST API. It may or may not be enabled at all wikis, but if you intend to query Wikipedia content.
The revision module of the \action API (linked to in #amirouche's answer) allows you to get the wikitext format of a page. That is the source format that is used by MediaWiki, and it isn't easy to get a HTML from it, which can be easier to analyze (especially if you do ĺingquistic analytics, for instance).
If HTML would be better for your use case, you can use the REST API, see https://en.wikipedia.org/api/rest_v1/#/. For instance, if you're interested in English Wikipedia's Main Page as of July 2008, you can use https://en.wikipedia.org/api/rest_v1/page/html/Main_Page/223883415.
The number (223883415) is the revision ID, which you can get through the action API.
However, keep in mind that re-parses the revision's wikitext into HTML. That means it doesn't need to be exactly what showed as of the date the revision was saved. For instance, the wikitext can contain conditions on current date (that is used for automatically upating the mainpage). If you're intereted in seeing that, you would need to use archive.org.
You can use the MediaWiki API to get revision; refer to the documentation at: https://www.mediawiki.org/wiki/API:Revisions.
You need to map revision ids with dates. It will be straightforward :).

Hide url in anchor tag

abcv
If i click this it's showing complete address. Problem is the path is shared and anyone can hack this path. Is there any way to not to show this entire path and only show abc.jpg in browser.
You may use following approaches
Store the images in the database and use HttpHandler to retrieve and display them.
As additional precaution you may pass current DateTime as encrypted url parameter to verify whether it is a fresh request within a specific time period say 10 minutes. You may refer this article for reference to HttpModule implementation
display-images-from-database-in-gridview-in-aspnet-using-handler-ashx-file-in-csharp-vbnet
As another approach you may implement the concept of Temporary URLs as described here Generating Temporary Download URLs
No. The complete path has to be shown so that browsers can retrieve the file.
You could implement a custom HTTP Handler or asp.net page that takes the name of the file in the query string and returns the contents of the file, perhaps even using a unique id (number, guid, etc,...) to map to each file to stop people "guessing" what other valid filenames may be. So, you'd have:
http://ipaddress/RetrieveUploadFile.aspx?fileid=36281
instead of
http://ipaddress/uplodfiles/2/abc.jpg
No, you don't want to "hide URL"; the whole notion would not make any sense, because all HTTP requests go with some URL. What you want is called URL rewriting:
Please refer this and this links

Wikipedia API - How to get all links from multiple pages?

I'm new to wiki api. I have read how to get all links from a specific page, and managed to do so, but in my case I need a list of links from many pages. And sending a request for each page is inefficient. This is the kind of request I use -
http://en.wikipedia.org/w/api.php?action=query&format=jsonfm&generator=links&gpllimit=500&redirects=true&pageids=1234
I must admit that I don't fully understand what each argument means. So -
How do you chain multiple pageids to 'pageids' argument? I guess that's a silly question but I didn't find any reference :\
Can the response point out which page owns each link?
Thanks!
You can just join page IDs (or names if you use the titles parameter) with | which is in general how you make lists in the MediaWiki API. I don't think there is a way to find out which link comes from which page, though.

Retrive data from mysql database with image in jsp servlet using AJAX on same page

I am working on online shopping website(e-commerce) website, in which I have a task to retrive products (product id, name, imageurl, price, details of product) Image having in image folder folder where stored images and that pah is given to database..
HereI want to fetch category on clicking menu categories without loading whole page needs to display on same page using AJAX.. Is there any solution??.
I don't have any Idea about Ajax and scripting to fetch images using scripting n all.. suggest me how can I resolve my problem using AJAX or JavaScript or jquery???
You need to write a bit of javascript code using the jquery library.
The jquery library will allow you to use ajax to access a special url in your web site to retrieve your category, say yourwebsite/categoryGet
This url's only task is to receive a parameter from the url, query your database accordingly, and return data either in html or in json format.
When your javascript receives the response through a callback function, it can update your page without reload.
This gives you an overview of your task, you should look for examples of using AJAX with jquery. It's not that complicated, really.
For instance, you can follow this tutorial: http://www.w3schools.com/jquery/jquery_ajax_intro.asp

Need to have many different URLS resolve to a single web page

And I don't want to use GET params.
Here are the details:
the user has a bunch of photos, and each photo must be shown by itself and have a unuique URL of the form
www.mysite.com/theuser/photoNumber-N
I create a unique URL for a user each time they add a new photo to their gallery
the web page that displays the user's photo is the same code for every user and every photo -- only the photo itself is different.
the user gives a URL to Person-A but then Person-A has one URL to that one photo and cannot see the user's other photos (because each photo has a unique URL and Person-A was given only one URL for one photo)
I want the following URLS to (somehow) end up loading only one web page with only the photo contents being different:
www.mysite/user-Terry/terryPhoto1
www.mysite/user-Terry/terryPhoto2
www.mysite/user-Jackie/JackiesWeddingPhoto
www.mysite/user-Jackie/JackiesDogPhoto
What I'm trying to avoid is this: having many copies of the same web page on my server, with the only difference being the .jpeg filename.
If I have 200 user and each has 10 photos -- and I fulfill my requirement that each photo is on a page by itself with a distinct URL -- right now I've got 2000 web pages, each displaying a unique photo, taking space on my web server and every page is identical and redundant disk-space-wasting HTML code, the only difference being the .JPEG file name of the photo to display.
Is there something I can do to avoid wasting diskspace and still meet my requirement that each photo has a unique URL?
Again I cannot use GET with parameters.
If you are on an Apache server, you can use Apache's mod_rewrite to accomplish just that. While the script you are writing will ultimately still be fetching GET variables (www.mysite.com/photos.php?id=photo-id), mod_rewrite will convert all the URL's served in the format you choose (www.mysite.com/user-name/photo-id).
Some ways you can implement it can be found here and here, while the actual documentation on the Apache module itself can be found here.
Go to IIS Manager. Go to the site hosted in IIS. Add additional binding for each url.
This will redirect all request the same location.