Not a lawyer. But text on wikipedia is under the Creative Commons license allowing you:
Under the following conditions:
- to Share—to copy, distribute and transmit the work, and
- to Remix—to adapt the work
- Attribution—You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work.)
- Share Alike—If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.
However... though even if it's quite clear even to every non-lawyer, it's not all that easy. As always.
- Attribution goes to the respective authors of the pages, not to Wikimedia Foundation. Which means you must look them up in the edits page first, and this leaves you with "names" like Pmsyyz, Andyvn22, 184.108.40.206, 220.127.116.11, 18.104.22.168, 22.214.171.124 and 200 others.
- You can be rather sure that Wikimedia Foundation sees (1.) differently. Even if they are rather obviously wrong, they can still sue you, at least in the USA. They may not win, but it will cost you thousands even before the first hearing.
- There are the Terms of Service in addition to the CC-SA, which you implicitly accept by visiting or downloading content from Wikipedia. This is about using their servers' CPU time and bandwidth, not about the actual content. Although the ToS read quite friendly at first sight (such as "wants to ensure that the content that we host can be re-used by other users without fear of liability and that it is not infringing the proprietary rights of others"), they are, like all ToS/EULAs far too long to read and understand in all its details without doing the equivalent of a PhD thesis.
- Even if it is explicitly allowed to use and adapt and share the content, the ToS (like all ToS) reserves the right for them to shut down your access. So, even if they do not have base for a lawsuit, Wikimedia Foundation can at any time take measures to prevent your program from using their service (and if you circumvent these, they do have a valid base for a lawsuit).