|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
- <head>
- <title>Web scraping</title>
- <meta charset="utf-8" />
- <meta name="author" content="Maxime Wack" />
- <link href="libs/remark-css-0.0.1/default.css" rel="stylesheet" />
- <script src="libs/htmlwidgets-1.5.1/htmlwidgets.js"></script>
- <script src="libs/jquery-1.12.4/jquery.min.js"></script>
- <link href="libs/datatables-css-0.0.0/datatables-crosstalk.css" rel="stylesheet" />
- <script src="libs/datatables-binding-0.10/datatables.js"></script>
- <link href="libs/dt-core-1.10.19/css/jquery.dataTables.min.css" rel="stylesheet" />
- <link href="libs/dt-core-1.10.19/css/jquery.dataTables.extra.css" rel="stylesheet" />
- <script src="libs/dt-core-1.10.19/js/jquery.dataTables.min.js"></script>
- <link href="libs/crosstalk-1.0.0/css/crosstalk.css" rel="stylesheet" />
- <script src="libs/crosstalk-1.0.0/js/crosstalk.min.js"></script>
- <link rel="stylesheet" href="css/my_style.css" type="text/css" />
- </head>
- <body>
- <textarea id="source">
-
-
-
-
- class: center, middle, title
-
- # UE Visualisation
-
- ### 2019-2020
-
- ## Dr. Maxime Wack
-
- ### AHU Informatique médicale
- #### Hôpital Européen Georges Pompidou, </br> Université de Paris
-
- ---
-
- # Web scraping
-
- ### Utilisation de `httr` et `rvest`
-
- ## httr
-
- Permet de faire des requêtes réseau
-
- → interroger et télécharger directement depuis R
-
- ## rvest
-
- Extraction de données depuis des pages HTML
-
- ---
-
- # httr
-
-
-
- Télécharger une page wikipedia
-
-
- ```r
- GET("https://en.wikipedia.org/wiki/Comparison_of_operating_systems") -> wiki
- ```
-
-
- ```
- ## Response [https://en.wikipedia.org/wiki/Comparison_of_operating_systems]
- ## Date: 2019-11-18 18:17
- ## Status: 200
- ## Content-Type: text/html; charset=UTF-8
- ## Size: 241 kB
- ## <!DOCTYPE html>
- ## <html class="client-nojs" lang="en" dir="ltr">
- ## <head>
- ## <meta charset="UTF-8"/>
- ## <title>Comparison of operating systems - Wikipedia</title>
- ## <script>document.documentElement.className="client-js";RLCONF={"wgBreakFrames...
- ## "Articles with unsourced statements from May 2018","Articles with unsourced s...
- ## "wgNoticeProject":"wikipedia","wgWikibaseItemId":"Q3345986","wgCentralAuthMob...
- ## "ext.gadget.watchlist-notice","ext.gadget.DRN-wizard","ext.gadget.charinsert"...
- ## <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.implement("user.tokens...
- ## ...
- ```
-
- ---
-
- # Parsing HTML
-
-
- ```r
- wiki %>%
- read_html -> wiki_html
- ```
-
-
- ```
- ## {html_document}
- ## <html class="client-nojs" lang="en" dir="ltr">
- ## [1] <head>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8 ...
- ## [2] <body class="mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject ...
- ```
-
- ---
-
- # Sélecteurs CSS
-
- [W3Schools](https://www.w3schools.com/cssref/css_selectors.asp)
-
- ### Selecteurs permettant d'identifier un **nœud** précis dans le **DOM** (Document Object Model) d'une page HTML
-
- ### Permet de sélectionner par identifiant, classe, position dans la hiérarchie, position entre élements d'un même niveau, ou relativement entre élements
-
- ### Utiliser l'**inspecteur** des outils de développement du navigateur pour identifier les éléments à capturer
-
- ---
-
- # Sélecteurs CSS
-
-
- ```r
- wiki_html %>%
- html_nodes(".wikitable")
- ```
-
- ```
- ## {xml_nodeset (4)}
- ## [1] <table class="wikitable sortable" style="font-size: smaller; text-align: ...
- ## [2] <table class="wikitable sortable" style="font-size: smaller; text-align: ...
- ## [3] <table class="wikitable" style="font-size: smaller; text-align: center; w ...
- ## [4] <table class="wikitable" style="font-size: smaller; text-align: center; w ...
- ```
-
-
- ```r
- wiki_html %>%
- html_node("div + .wikitable")
- ```
-
- ```
- ## {html_node}
- ## <table class="wikitable sortable" style="font-size: smaller; text-align: center; width: auto; sortby: name;">
- ## [1] <tbody>\n<tr>\n<th>Name\n</th>\n<th>Creator\n</th>\n<th abbr="Initial rel ...
- ```
-
- ---
-
- # Extraction d'une table
-
-
- ```r
- wiki_html %>%
- html_node("div + .wikitable") %>%
- html_table -> wikitable
- ```
-
- <div id="htmlwidget-091df5e78bc68f820c56" style="width:100%;height:auto;" class="datatables html-widget"></div>
- <script type="application/json" data-for="htmlwidget-091df5e78bc68f820c56">{"x":{"filter":"none","data":[["AIX","Android","AmigaOS classic","AmigaOS 4","Chrome OS","DragonFly BSD","FreeBSD","Genode","GhostBSD","eComStation","EPOC32","GNU/Linux","Haiku","HP-UX","IBM i","Inferno","iOS","IRIX","Classic Mac OS","MVS","macOS","macOS Server","MPE","MCP","MPE/XL","MINIX 3","NetBSD","NetWare","NeXTSTEP","OpenBSD","OpenIndiana","OpenVMS","OS/360","OS/390","OS 2200","OS/2","Plan 9","QNX","Solaris","Symbian","Symbian platform","Windows Server (NT family)","Windows (NT family)","Windows (classic 9x family)","RISC iX","RISC OS","RISC OS 4","RISC OS 5","RISC OS 6","ZETA","STOP 6, XTS-400","ReactOS","TrueOS","VxWorks","z/OS","z/VSE","z/VM","HP NonStop","Name"],["IBM","Android, Inc., Google","Commodore International, Haage & Partner, Hyperion Entertainment","Hyperion Entertainment","Google","Matthew Dillon","The FreeBSD Project","Genode Labs","Eric Turgeon","Serenity Systems, Mensys BV","Psion PLC","Notable contributors include: Richard Stallman for GNU Project and Linus Torvalds for Linux and the Unixes they emulated; Red Hat, Debian Project See: Comparison of Linux distributions and Linux Kernel#Development","Haiku Inc.","Hewlett-Packard","IBM","Bell Labs","Apple Inc.","SGI","Apple Inc.","IBM","Apple Inc.","Apple Inc.","HP","Unisys","HP","Andrew S. Tanenbaum","The NetBSD Project","Novell","NeXT","The OpenBSD Project","Many, based on software developed by Sun Microsystems and many others","DEC (now VSI)","IBM","IBM","Unisys","IBM and Microsoft","Bell Labs","QNX Software Systems","Sun, Oracle Corporation","Symbian Ltd.","Symbian Foundation","Microsoft","Microsoft","Microsoft","Acorn Computers","Acorn Computers","RISCOS Ltd, Pace plc","Castle Technology, RISC OS Open","RISCOS Ltd","yellowTAB","BAE Systems","ReactOS development team","PC-BSD Software","Wind River Systems","IBM","IBM","IBM","HP","Creator"],["1986","2008","1985","2004","2009","2003","1993","2008","2009","2001","1996","1991 (kernel), See: Comparison of Linux distributions and History of Linux","2009","1983","1988","1997","2007","1988","1984","1972","2001","2001","1974","1961","1987","2005","1993","1985","1989","1995","2010","1977","1966","1995","1967 as Exec 8e","1987","1993","1982","1992","1998","2010 (initially 1998 as Symbian)","1993","1993","1995","1988","1987","1999","2002","2006","2005","2003","1996","2006","1987","2000","2007","2000","1974","Initial public release"],["UNIX System V Release 3","None","TRIPOS (as the disk operating component of AmigaOS)","AmigaOS classic","Chromium OS","FreeBSD","386BSD","None","FreeBSD","OS/2","","None","BeOS R5","UNIX System V","OS/400","Plan 9","macOS","UNIX System V","None[g 2][g 3]","OS/360","NeXTSTEP, BSD","NeXTSTEP, BSD","None","None","MPE","Minix2","386BSD","S-Net","Unix","NetBSD 1.0","OpenSolaris","RSX-11M","None","MVS","Exec 8, OS 1100","MS-DOS","Unix","Unix, POSIX","SunOS","EPOC32","Symbian","OS/2, Windows 3.x and MS-DOS","OS/2, Windows 9x and MS-DOS","MS-DOS, Windows NT 3.5","BSD 4.3","Arthur, also the BBC Master OS","RISC OS","RISC OS 4","RISC OS 4","BeOS R5","STOP 5, XTS-300","Windows NT","FreeBSD[g 5]","VRTX","OS/390","VSE/ESA","VM","Guardian","Predecessor"],["7.2","10","3.9 BB2","4.1 Final Edition","75.0.3770.102","5.6.1","12.0","19.05[1]","19.04[2]","2.1","ER5","4.19 (kernel)","R1/Beta","11i v3 Update 16","7.3","Fourth Edition","13.1","6.5.30","9.2.2","MVS/ESA SP - JES3 Version 5 R2.2","10.14.6 Mojave","10.12 / September 20, 2016","MPE-V","CP OS 17.0","7.5","3.3.0","8.1","6.5 SP8","3.3","6.5","2019.04","8.4-2L2","Operating System/360 R21.8","OS/390 Version 2 R10","CP OS 16 (Exec 49.2)","4.52","Fourth Edition","7.0.0","11.4","9.5","3.0.4","Windows Server 2019 (Version 10.0.17763)","Windows 10 (Version 1903)","Windows Me (Win 4.90.3000)","1.21c","3.71","4.39","5.24[6]","6.20","1.5","6.5","0.4.10","10.1[7]","7","Version 2.3 (V2R3)","6.2","6.4","H06.24/J06.13","Current stable version"],["2015, October 5","2019, September 3","2002, March 20","2014","2019, March 5","2019, June 19","2018, December 11","2019, May 29","2019, April 13","2011","1999","2018, October 22 (kernel)","2018, September 29","2017, May","2016, April 15","2009, June 30","2019, September 24","2006","2000","1995, September 29","2019, August 26","2016, September 20","1988","2015, April","2002","2014","2019, May 31","2009, May 6","1995","2019, May 1","2017, May 3[3]","2017, July 10","1972, August","2000, September 29","2015, February 27","2001","2003 (except for minor later updates)","2017, March","2018, August 28","2009","2010","2018, October 2","2019, May 21","2000","1993","1997","2004","2018","2009","2007","2008, August","2018, November 6","2014, November 16","2014 March","2017, September 29","2017, December 1","2016, November 11","2012","Release date"],["Bundled with hardware","Free","Discontinued; Bundled with hardware up to version 3.0 (Amiga International hardware came with 3.1); versions 2.1, 3.0, 3.1, 3.5, 3.9 also available as separate packages","4.0 bundled with hardware; 4.0 for classic and 4.1 available as standalone package at €29","Bundled with hardware, 32-bit edition dropped","Free","Free","Free, source code only","Free","Home-student edition (max. three per site) US$145.00 (equivalent to $161.49 in 2018)business edition $290.00","Discontinued; Commercial","Free","Free","US$400","Bundled with hardware","Free","Bundled with hardware and free updates given to most existing users, subject to hardware requirements","Discontinued; Bundled with hardware","Discontinued; Was bundled with 68k and PowerPC Macs;\nversions 7-9 sold as retail upgrades[g 4]","Bundled with hardware","Bundled with hardware; No-cost update via Mac App Store for users of Mac OS X 10.6 or later, assuming hardware requirements are met","Previously bundled with hardware; No longer a separate operating system, but a group of services installed atop any current version of Mac OS X; US$19.99 on the Mac App Store","Discontinued; Was bundled with HP-3000 CISC hardware \"Classic\"","Bundled with hardware","Discontinued; Was bundled with HP-3000 PA-RISC hardware","Free","Free","Superseded by Novell Open Enterprise Server; Was US$184 (equivalent to $214.88 in 2018) (one-user)","Discontinued; Was bundled with hardware, then sold separately","Free","Free","Commercial, free non-commercial use","Bundled with hardware","Bundled with hardware","Bundled with hardware","Discontinued (see eComStation successor); Was US$300 (equivalent to $424.49 in 2018)","Free","Bundled with BlackBerry 10 and PlayBook devices. Commercial; an academic version exists that needs authorization code before installing","Commercial; (but free/no-cost perpetual license when used \"for the purpose of developing, testing, prototyping and demonstrating your applications\"[4])","Discontinued; Commercial","Free","US$1050 5 CALs server; other editions dependent on number of CALs purchased","Windows 10 Home US$119, Windows 10 Pro US$199[5]","Discontinued","Discontinued; Was bundled with hardware","Discontinued; Was bundled with hardware","Bundled with hardware, then sold separately at £70 (US$127)","Free","Bundled with hardware, then sold separately at £70 (US$127)","Discontinued","US$60,000 (equivalent to $69,821 in 2018)+; bundled with XTS hardware and OEM licensed","Free","Free","Paid","Monthly license fee, about US$130 and up","Monthly license fee","Monthly license fee","Non-free","Cost, availability"],["Proprietary","Apache 2.0, GNU GPLv2","Proprietary, open source clone available under AROS Public License","Proprietary","Proprietary: Google OS Terms of Service","BSD","BSD","AGPL","BSD","Proprietary","Proprietary","GNU GPLv2 (kernel)","MIT","Proprietary","Proprietary","MIT, GNU GPL, GNU LGPL, LPL","Proprietary higher level API layers; open source core system (ARM versions): APSL, GNU GPL, others","Proprietary","Proprietary","Proprietary","Proprietary higher level API layers; open source core system (Intel-PowerPC versions): APSL, GNU GPL, others","Proprietary higher level API layers; open source core system (Intel-PowerPC versions): APSL, GNU GPL, others","Proprietary","Proprietary","Proprietary","BSD","BSD","Proprietary","Proprietary","ISC","CDDL","Proprietary","Proprietary","Proprietary","Proprietary","Proprietary","LPL","Proprietary","CDDL","Proprietary","EPL","Proprietary; Source-available","Proprietary; Source-available","Proprietary","Proprietary","Proprietary","Proprietary","Apache License","Proprietary","Proprietary","Proprietary","GNU GPL, GNU LGPL","BSD","Proprietary","Proprietary","Proprietary","Proprietary","Proprietary","Preferred license[g 1]"],["Server, NAS, workstation","Smartphone, tablet computer, education","Workstation, personal computer","Workstation, personal computer","Chromebook, Chromebox, Chromebase and tablets","Server, workstation, NAS, embedded","Server, workstation, NAS, embedded","Desktop, Embedded, Server","Desktop, workstation","Server, workstation, personal computer","PDA","See: Comparison of Linux distributions","Personal computer","Server","Server","NAS, server, embedded","Smartphone, music player, tablet computer","Server, workstation","Workstation, personal computer","IBM mainframe","Workstation, personal computer, embedded","Server","Server","Server","Server","Workstation","NAS, server, workstation, embedded","Server","Workstation","Server, NAS, workstation, embedded","Server, workstation","Server, workstation","IBM mainframe","IBM mainframe","Server","Personal computer, server","Workstation, server, embedded, HPC","Automotive, medical, smartphones, consumer, industrial, embedded, safety","Server, workstation","Phones","embedded","Server, NAS, embedded","Workstation, personal computer, media center, Tablet PC, embedded","Personal computer, media center","Workstation","Education, personal computer","Education, personal computer","Education, personal computer","Education, personal computer","Personal computer, media center, workstation","Server, workstation","Workstation, personal computer","Personal computer, workstation, server","Embedded Real-time systems","IBM mainframe","IBM mainframe","IBM mainframe","HP Nonstop Servers","Target system type"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th>Name<\/th>\n <th>Creator<\/th>\n <th>Initial public release<\/th>\n <th>Predecessor<\/th>\n <th>Current stable version<\/th>\n <th>Release date<\/th>\n <th>Cost, availability<\/th>\n <th>Preferred license[g 1]<\/th>\n <th>Target system type<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"paging":false,"info":false,"searching":false,"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
-
- ---
-
- # Exercices
-
- ### Transformer cette table en forme normale
-
- ### Extraire la table avec les informations techniques
-
- ### Identifier les OS libres fonctionnant avec un microkernel
- </textarea>
- <style data-target="print-only">@media screen {.remark-slide-container{display:block;}.remark-slide-scaler{box-shadow:none;}}</style>
- <script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
- <script src="addons/macros.js"></script>
- <script>var slideshow = remark.create({
- "ratio": "4:3",
- "countIncrementalSlides": false,
- "self-contained": true,
- "highlightLines": true
- });
- if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
- window.dispatchEvent(new Event('resize'));
- });
- (function(d) {
- var s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
- if (!r) return;
- s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
- d.head.appendChild(s);
- })(document);
-
- (function(d) {
- var el = d.getElementsByClassName("remark-slides-area");
- if (!el) return;
- var slide, slides = slideshow.getSlides(), els = el[0].children;
- for (var i = 1; i < slides.length; i++) {
- slide = slides[i];
- if (slide.properties.continued === "true" || slide.properties.count === "false") {
- els[i - 1].className += ' has-continuation';
- }
- }
- var s = d.createElement("style");
- s.type = "text/css"; s.innerHTML = "@media print { .has-continuation { display: none; } }";
- d.head.appendChild(s);
- })(document);
-
-
- (function() {
- var deleted = false;
- slideshow.on('beforeShowSlide', function(slide) {
- if (deleted) return;
- var sheets = document.styleSheets, node;
- for (var i = 0; i < sheets.length; i++) {
- node = sheets[i].ownerNode;
- if (node.dataset["target"] !== "print-only") continue;
- node.parentNode.removeChild(node);
- }
- deleted = true;
- });
- })();
-
-
- (function(d) {
- const hlines = d.querySelectorAll('.remark-code-line-highlighted');
- const preParents = [];
- const findPreParent = function(line, p = 0) {
- if (p > 1) return null;
- const el = line.parentElement;
- return el.tagName === "PRE" ? el : findPreParent(el, ++p);
- };
-
- for (let line of hlines) {
- let pre = findPreParent(line);
- if (pre && !preParents.includes(pre)) preParents.push(pre);
- }
- preParents.forEach(p => p.classList.add("remark-code-has-line-highlighted"));
- })(document);</script>
-
- <script>
- (function() {
- var links = document.getElementsByTagName('a');
- for (var i = 0; i < links.length; i++) {
- if (/^(https?:)?\/\//.test(links[i].getAttribute('href'))) {
- links[i].target = '_blank';
- }
- }
- })();
- </script>
-
- <script>
- slideshow._releaseMath = function(el) {
- var i, text, code, codes = el.getElementsByTagName('code');
- for (i = 0; i < codes.length;) {
- code = codes[i];
- if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
- text = code.textContent;
- if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
- /^\$\$(.|\s)+\$\$$/.test(text) ||
- /^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
- code.outerHTML = code.innerHTML;
- continue;
- }
- }
- i++;
- }
- };
- slideshow._releaseMath(document);
- </script>
-
- <script>
- (function () {
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = 'https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML';
- if (location.protocol !== 'file:' && /^https?:/.test(script.src))
- script.src = script.src.replace(/^https?:/, '');
- document.getElementsByTagName('head')[0].appendChild(script);
- })();
- </script>
- </body>
- </html>
|