7

この例ではUNIXのウィキペディアの記事のテキストの最初の段落を取得しようとしていますが、望ましくない出力が返されます。

私がウィキペディア API とここ StackOverflow で読んできたものについては、これは呼び出しを行うためのリクエスト URL です。

http://en.wikipedia.org/w/api.php?format=php&action=query&titles=unix&redirects=1&prop=revisions&rvprop=content&rvsection=0&rvlimit=1

私の予想される出力は次のようになります。

Unix (正式には UNIX として商標登録され、小文字で Unix と表記されることもあります) は、1969 年に Ken Thompson、Dennis Ritchie、Brian Kernighan、ダグラス・マキロイ、マイケル・レスク、ジョー・オサナ[1] Unix オペレーティング システムは、最初はアセンブリ言語で開発されましたが、1973 年までにほぼ完全に C でコーディングされたため、さらなる開発と他のハードウェアへの移植が大幅に容易になりました。今日の Unix システムの進化は、AT&T だけでなく、さまざまな商用ベンダー、大学 (カリフォルニア大学バークレー校の BSD など)、および非営利組織によって時間をかけて開発されたさまざまなブランチに分割されています。

私の現在の結果:

{{Use dmy dates|date=August 2012}}
{{Infobox OS
|name               = Unix
|logo               = 
|screenshot         = [[File:Unix history-simple.svg|250px]]
|caption            = Evolution of Unix and Unix-like systems
|website            = [http://www.unix.org unix.org]
|developer          = [[Ken Thompson (computer programmer)|Ken Thompson]], [[Dennis Ritchie]], [[Brian Kernighan]], [[Douglas McIlroy]], and [[Joe Ossanna]] at [[Bell Labs]]
|source_model       = Historically [[Closed source software|closed source]], now some Unix projects ([[Berkeley Software Distribution|BSD]] family and [[Illumos]]) are [[open source]]d.
|frequently_updated = yes <!-- Release version update? Don't edit this page, just click on the version number! -->
|programmed_in      = [[C (programming language)|C]] 
|kernel_type        = [[Monolithic Kernel|Monolithic]]
|ui                 = [[Command-line interface]] & [[Graphical user interface|Graphical]] ([[X Window System]])
|language           = English 
|family             = Unix
|released           = {{start date and age|df=yes|1969}}
|license            = [[Proprietary software|Proprietary]]
|working_state      = Current 
}}

'''Unix''' (officially trademarked as '''UNIX''', sometimes also written as '''<span style="font-variant: small-caps;">Unix</span>''' in small caps) is a [[Computer multitasking|multitasking]], [[multi-user]] computer [[operating system]] originally developed in 1969 by a group of [[American Telephone & Telegraph|AT&T]] employees at [[Bell Labs]], including [[Ken Thompson]], [[Dennis Ritchie]], [[Brian Kernighan]], [[Douglas McIlroy]], [[Michael Lesk]] and [[Joe Ossanna]].<ref name=" Ritchie">{{cite journal
  | last = Ritchie
  | first = D.M.
  | authorlink = 
  | coauthors = Thompson, K.
  | title = The UNIX Time-Sharing System
  | journal = Bell System Tech. J.
  | volume = 57
  | issue = 6
  | pages = 1905-1929
  | publisher = American Tel. & Tel.
  | location = USA
  | date = July 1978
  | url = http://www.alcatel-lucent.com/bstj/vol57-1978/articles/bstj57-6-1905.pdf
  | issn = 
  | doi = 
  | id = 
  | accessdate = December 9, 2012}}</ref>  The Unix operating system was first developed in [[assembly language]], but by 1973 had been almost entirely recoded in [[C (programming language)|C]], greatly facilitating its further development and [[Software portability|porting]] to other hardware. Today's Unix system evolution is split into various branches, developed over time by AT&T as well as various commercial vendors, universities (such as [[University of California, Berkeley]]'s [[BSD]]), and [[non-profit]] organizations.

[[The Open Group]], an industry standards consortium, owns the UNIX trademark. Only systems fully compliant with and certified according to the [[Single UNIX Specification]] are qualified to use the trademark; others might be called ''Unix system-like'' or ''[[Unix-like]]'', although the Open Group disapproves<ref>[http://www.unix.org/questions_answers/faq.html#7a  What is a "Unix-like" operating system?] Unix.org FAQ</ref> of this term.  However, the term ''Unix'' is often used informally to denote any operating system that closely resembles the trademarked system.

During the late 1970s and early 1980s, the influence of Unix in academic circles led to large-scale adoption of Unix (particularly of the [[Berkeley Software Distribution|BSD]] variant, originating from the [[University of California, Berkeley]]) by commercial startups, the most notable of which are [[Solaris (operating system)|Solaris]], [[HP-UX]], [[Sequent Computer Systems|Sequent]], and [[AIX operating system|AIX]], as well as [[Darwin (operating system)|Darwin]], which forms the core set of components upon which [[Apple Inc.|Apple]]'s [[OS X]], [[Apple TV]], and [[IOS (Apple)|iOS]] are based.<ref>{{cite web|url=http://marketshare.hitslink.com/operating-system-market-share.aspx?qprid=8&qpcustomd=0 |title=Operating system market share |publisher=Marketshare.hitslink.com |date= |accessdate=2012-08-22}}</ref><ref>{{cite web|url=http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemTechnology/SystemTechnology.html#//apple_ref/doc/uid/TP40001067-CH207-BCICAIFJ |title=Loading |publisher=Developer.apple.com |date= |accessdate=2012-08-22}}</ref> Today, in addition to certified Unix systems such as those already mentioned, [[Unix-like]] operating systems such as [[MINIX]], [[Linux]], and [[BSD]] descendants ([[FreeBSD]], [[NetBSD]], [[OpenBSD]], and [[DragonFly BSD]]) are commonly encountered. The term ''traditional Unix'' may be used to describe an operating system that has the characteristics of either [[Version 7 Unix]] or [[UNIX System V]]."

記事を取得する正しい方法は何ですか?

前もって感謝します!

4

4 に答える 4

6

プレーンテキストのみが必要な場合は、TextExtractsを使用します: http://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&explaintext=1&titles=Unix

これにより、次が生成されます。Unix is a multitasking, multi-user computer operating system that exists in many variants. The original Unix was developed at AT&T's Bell Labs research center by Ken Thompson, Dennis Ritchie, and others. From the power user's or programmer's perspective, Unix systems are characterized by a modular design that is sometimes called the "Unix philosophy," meaning the OS provides a set of simple tools that each perform a limited, well-defined function, with a unified filesystem as the main means of communication and a shell scripting and command language to combine the tools to perform complex workflows.

于 2014-04-22T06:32:30.873 に答える
0

MobileFrontend Extensionをチェックアウトします。少なくとも、いくつかの<p>作業が可能になります。http://en.wikipedia.org/w/api.php?format=json&action=mobileview&page=Unix§ions=0&prop=text|sectionsを使用すると、

{"mobileview":{"sections":[{"id":0,"text":"\nUnix\n\n
\nUnix および Unix 系システムの進化\n\n\n\n会社 / 開発者\nKen Bell Labs の Thompson、Dennis Ritchie、Brian Kernighan、Douglas McIlroy、Joe Ossanna\n\n\n\nC およびアセンブリ言語でプログラム\n\n\nOS ファミリ\nUnix\n\n\n動作状態\n現在\n\ n\nソース モデル\n歴史的にクローズド ソースでしたが、現在は一部の Unix プロジェクト (BSD ファミリと Illumos) がオープン ソース化されています。\n\n\n初回リリース\n1969 年 4 月 20 日; 44 年前 (1969 年 4 月 20 日)\n\n\ n利用可能な言語\n英語\n\n\nカーネル タイプ\nモノリシック\n\n\nデフォルトのユーザー インターフェース\nコマンドライン インターフェースとグラフィカル(X Window System)\n\n\nライセンス\n独自\n\n\n公式Web サイト\nhttp://www.unix.org\">unix.org\n\n\n

Unix (公式にはUNIXとして商標登録されており、小文字でUnixと表記されることもあります) は、1969 年にグループによって最初に開発された、マルチタスク、マルチユーザーのコンピューター オペレーティング システムです。

(をちょきちょきと切る)

それを取得して別の方法 (perl、bash など) で解析する必要がありますが、その時点で、API を捨てて何らかのcurlアクションwgetを実行すると、簡単になります。

于 2013-07-23T22:19:46.733 に答える
0

この URLを試してください。

(注: pagename は、リクエストしているページです)

しかし、これはたくさんの html がらくたを返します...これを行うことで hml をフィルタリングできます:

$.getJSON("http://en.wikipedia.org/w/api.php?"+"action=parse&format=json&prop=text&section=all&page=" + entry + "&redirects&callback=?", function(data)
    {   

        if (!data.error)
        {
            var markup = data.parse.text["*"];
            if (typeof markup !== "undefined")
            {
                $("#entry").text(entry).show();
                var blurb = $('<div id="articleText"></div>').html(markup);

                // remove links as they will not work
                blurb.find('a').each(function() { $(this).replaceWith($(this).html()); });

                // remove any references
                blurb.find('sup').remove();

                // remove cite error
                blurb.find('.mw-ext-cite-error').remove();
                $('#article').html($(blurb).find('p'));

                $("#article").append(link);
                // console.log(markup);
            }
        }
    });

詳細はこちら

于 2014-09-29T11:26:27.533 に答える