diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 6cc9e52..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,9 +0,0 @@ -Please delete the text below before submitting your contribution. - ---- - -Thanks for contributing! If this contribution is for instructor training, please send an email to checkout@carpentries.org with a link to this contribution so we can record your progress. You’ve completed your contribution step for instructor checkout just by submitting this contribution. - -Please keep in mind that lesson maintainers are volunteers and it may be some time before they can respond to your contribution. Although not all contributions can be incorporated into the lesson materials, we appreciate your time and effort to improve the curriculum. If you have any questions about the lesson maintenance process or would like to volunteer your time as a contribution reviewer, please contact Kate Hertweck (k8hertweck@gmail.com). - ---- diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6cc9e52..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,9 +0,0 @@ -Please delete the text below before submitting your contribution. - ---- - -Thanks for contributing! If this contribution is for instructor training, please send an email to checkout@carpentries.org with a link to this contribution so we can record your progress. You’ve completed your contribution step for instructor checkout just by submitting this contribution. - -Please keep in mind that lesson maintainers are volunteers and it may be some time before they can respond to your contribution. Although not all contributions can be incorporated into the lesson materials, we appreciate your time and effort to improve the curriculum. If you have any questions about the lesson maintenance process or would like to volunteer your time as a contribution reviewer, please contact Kate Hertweck (k8hertweck@gmail.com). - ---- diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cf3b859..0000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*.pyc -*~ -.DS_Store -.ipynb_checkpoints -.sass-cache -__pycache__ -_site diff --git a/AUTHORS b/AUTHORS old mode 100644 new mode 100755 index abef910..bb7ce40 --- a/AUTHORS +++ b/AUTHORS @@ -1,2 +1 @@ -Thomas Guignard -Joel Nothman +Thomas Guignard \ No newline at end of file diff --git a/CITATION b/CITATION old mode 100644 new mode 100755 diff --git a/CONDUCT.md b/CONDUCT.md old mode 100644 new mode 100755 index 5e4943b..e83b08f --- a/CONDUCT.md +++ b/CONDUCT.md @@ -32,14 +32,13 @@ or other unprofessional conduct. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to our [Code of Conduct][coc]. +that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. Instances of abusive, harassing, or otherwise unacceptable behavior -may be reported by following our [reporting guidelines][coc-reporting]. +may be reported by opening an issue or contacting one or more of the project maintainers. +This Code of Conduct is adapted from +the [Contributor Covenant][contrib-covenant] Version 1.0.0. -- [Software and Data Carpentry Code of Conduct][coc] -- [Code of Conduct Reporting Guide][coc-reporting] - -{% include links.md %} +[contrib-covenant]: http://contributor-covenant.org/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md old mode 100644 new mode 100755 index d711471..2f48ba0 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,8 +46,8 @@ and to meet some of our community members. ## Where to Contribute 1. If you wish to change this lesson, - please work in , - which can be viewed at . + please work in , + which can be viewed at . 2. If you wish to change the example lesson, please work in , @@ -145,8 +145,8 @@ You can also [reach us by email][contact]. [github-flow]: https://guides.github.com/introduction/flow/ [github-join]: https://github.com/join [how-contribute]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github -[issues]: https://github.com/data-lessons/library-webscraping/issues/ -[repo]: https://github.com/data-lessons/library-webscraping +[issues]: https://github.com/timtomch/library-webscraping/issues/ +[repo]: https://github.com/timtomch/library-webscraping [swc-issues]: https://github.com/issues?q=user%3Aswcarpentry [swc-lessons]: http://software-carpentry.org/lessons/ [swc-site]: http://software-carpentry.org/ diff --git a/LICENSE.md b/LICENSE.md old mode 100644 new mode 100755 index 179758a..566ce55 --- a/LICENSE.md +++ b/LICENSE.md @@ -73,7 +73,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## Trademark -"Software Carpentry" and "Data Carpentry" and their respective logos +"Software Carpentry" an "Data Carpentry" and their respective logos are registered trademarks of [NumFOCUS][numfocus]. [cc-by-human]: https://creativecommons.org/licenses/by/4.0/ diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index b5dfe2f..0f395a3 --- a/Makefile +++ b/Makefile @@ -9,7 +9,6 @@ DST=_site # Controls .PHONY : commands clean files -.NOTPARALLEL: all : commands ## commands : show all commands. @@ -17,11 +16,11 @@ commands : @grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g' ## serve : run a local server. -serve : lesson-md +serve : lesson-rmd ${JEKYLL} serve ## site : build files but do not run a server. -site : lesson-md +site : lesson-rmd ${JEKYLL} build # repo-check : check repository settings. @@ -54,7 +53,7 @@ workshop-check : ## ---------------------------------------- ## Commands specific to lesson websites. -.PHONY : lesson-check lesson-md lesson-files lesson-fixme +.PHONY : lesson-check lesson-rmd lesson-files lesson-fixme # RMarkdown files RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd) @@ -80,16 +79,13 @@ HTML_DST = \ $(patsubst _extras/%.md,${DST}/%/index.html,$(wildcard _extras/*.md)) \ ${DST}/license/index.html -## lesson-md : convert Rmarkdown files to markdown -lesson-md : ${RMD_DST} - -# Use of .NOTPARALLEL makes rule execute only once -${RMD_DST} : ${RMD_SRC} - @bin/knit_lessons.sh ${RMD_SRC} +## lesson-rmd : convert Rmarkdown files to markdown +lesson-rmd: $(RMD_SRC) + @bin/knit_lessons.sh $(RMD_SRC) ## lesson-check : validate lesson Markdown. lesson-check : - @bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md + @bin/lesson_check.py -s . -p ${PARSER} ## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace. lesson-check-all : diff --git a/README.md b/README.md deleted file mode 100644 index 2e43e6d..0000000 --- a/README.md +++ /dev/null @@ -1,45 +0,0 @@ -This material has now been moved to the Library Carpentry organisation. - -Find it here: https://github.com/LibraryCarpentry/lc-webscraping - -# Library Carpentry - -The Library Carpentry module '[Web Scraping for Librarians](http://data-lessons.github.io/library-webscraping/)' is maintained by [Belinda Weaver](https://github.com/weaverbel) and [Thomas Guignard](https://github.com/timtomch). - -## Background - -Library Carpentry is a software skills training programme aimed at library and information -professions. It builds on the work of [Software Carpentry](http://software-carpentry.org/) and -[Data Carpentry](http://www.datacarpentry.org/). - -Library Carpentry is in the commons and for the commons. It is not tied to any institution of person. For more information on Library Carpentry, see our website [librarycarpentry.github.io](http://librarycarpentry.github.io/). - -## Contribution - -There are many ways of contributing to Library Carpentry: - -- Join our [Gitter discussion forum](https://gitter.im/LibraryCarpentry/). -- Follow updates on [Twitter](https://twitter.com/LibCarpentry). -- Make a suggestion or correct an error by [raising an Issue](https://github.com/data-lessons/library-webscraping/issues). - -## Code of Conduct - -All participants should agree to abide by the -[Software Carpentry Code of Conduct](http://software-carpentry.org/conduct/). - -## Authors - -Library Carpentry is authored and maintained by the -[community](https://github.com/data-lessons/library-webscraping/network/members). - -## Citation - -Please cite as: - -Library Carpentry. Web Scraping for Librarians. June 2017. -http://data-lessons.github.io/library-webscraping/. - -## Attribution - -This course is derived from work copyrighted by [Software Carpentry](http://software-carpentry.org/) -under the [CC BY 4.0 license](https://creativecommons.org/licenses/by/4.0/) diff --git a/_config.yml b/_config.yml old mode 100644 new mode 100755 index f14b3bd..50c678e --- a/_config.yml +++ b/_config.yml @@ -2,16 +2,14 @@ # Values for this lesson. #------------------------------------------------------------ -# Which carpentry is this ("swc", "dc", or "lc")? -carpentry: "lc" +# Which carpentry is this ("swc" or "dc")? +carpentry: "dc" # Overall title for pages. title: "Introduction to web scraping" -# Contact. This *must* include the protocol: if it's an email -# address, it must look like "mailto:lessons@software-carpentry.org", -# or if it's a URL, "https://gitter.im/username/ProjectName". -contact: "https://gitter.im/LibraryCarpentry/" +# Contact email address. +email: tom@timtom.ch #------------------------------------------------------------ # Generic settings (should not need to change). diff --git a/_episodes/.gitkeep b/_episodes/.gitkeep old mode 100644 new mode 100755 diff --git a/_episodes/01-introduction.md b/_episodes/01-introduction.md old mode 100644 new mode 100755 index 80c3512..f749032 --- a/_episodes/01-introduction.md +++ b/_episodes/01-introduction.md @@ -1,5 +1,5 @@ --- -title: "What is web scraping?" +title: "Introduction: What is web scraping?" teaching: 10 exercises: 0 questions: @@ -15,177 +15,100 @@ keypoints: - "Web scraping is the process of automating the extraction of data from web sites." --- -# What is web scraping? +## What is web scraping? -Web scraping is a technique for **targeted, automated extraction of information from websites**. +Web scraping is a technique for extracting information from websites. This can be done manually +but it is usually faster, more efficient and less error-prone if it can be automated. -Similar extraction can be done manually but it is usually faster, more efficient and less error-prone to automate the task. +Web scraping allows you to convert non-tabular or poorly structured data into a usable, structured format, +such as a .csv file or spreadsheet. -Web scraping allows you to acquire non-tabular or poorly structured data from websites and convert it -into a usable, structured format, such as a .csv file or spreadsheet. +Scraping can help you acquire data made inaccessible by the way it has been presented online. +But scraping is about more than just acquiring data: it can help you track changes to data online, and +help you archive data. In short, it's a skill worth learning. -Scraping is about more than just acquiring data: it can also help you archive data and track changes to data online. +It is closely related to the practice of +web _indexing_, which is what search engines like Google do when mass analysing the Web to build +their index. But contrary to _web indexing_, which typically parses the entire content of a web +page to make it searchable, _web scraping_ targets specific information on the pages visited. -For example: +For example, online stores will often scour the publicly available pages of their competitors, +scrape item prices, and then use this information to adjust their own prices. Another common +practice is "contact scraping" in which contact information (such as email +addresses or phone numbers) is collected for marketing purposes. -* Online stores will periodically scour the publicly available pages of their competitors, - scrape **item names and prices** and then use this information to adjust their own prices. -* Marketing databases may be compiled by scraping **contact information** such as email - addresses. +Web scraping is also increasingly being used by scholars to create data sets for +text mining projects, say, collections of journal articles or digitised texts. The practice of +[data journalism](https://en.wikipedia.org/wiki/Data_journalism), in particular, relies on the +ability for investigative journalists to harvest data that is not always published in a form +that allows analysis. -Applications of scraping in research and journalism may include: +## Before you get started -* tracking trends in the real estate market by scraping data from real estate - web sites -* collecting online article comments and other discourse for analysis (e.g. using text mining) -* gathering data on membership and activity of online organisations -* collecting archives of reports from many web pages +As useful as scraping is, there might be better options. Choose the right (i.e. the easiest) tool for the job. -The practice of -[data journalism](https://en.wikipedia.org/wiki/Data_journalism), in particular, relies on the -ability of investigative journalists to harvest data that is not always presented or published in a form -that allows analysis. +- Check whether or not you can copy and paste data from a site into Excel or Google Sheets. +- Look for existing structured data (it may exist). +- use Freedom of information requests (be specific about the format you want data in). -### Behind the web's facade - -At the heart of the problem which web scraping solves is that the web is -(mostly) designed for humans. Very often, web sites are built to display -**structured content** which is stored in a database on a web server. Yet they -tend to provide content in a way that loads quickly, is useful for someone with -a mouse or a touchscreen, and looks good. They format the structured content -with templates, surround it with boilerplate content like headers, make parts -of it shown or hidden with the click of a mouse. Such presentation is often -called **unstructured**. - -In other cases, the data presented in a web site has been edited or collated -manually, and does not present some underlying structured database. - -Web scraping aims to transform specific content in a web site into a structured -form: a database, a spreadsheet, an XML representation, etc. - -Web designers expect that readers will interpret the content by using prior -knowledge of what a header looks like, what a menu looks like, what a *next -page* link looks like, what a person's name, a location, an email address. -Computers do not have this intuition. - -Web scraping therefore involves: - -* telling a computer how to __navigate__ through a web site to find required - content (sometimes called ___spidering___); and -* providing ___patterns___ with which the computer can identify and __extract__ - required content. - -### Not web scraping: structured content on the web - -There are, however, many forms of structured content on the web, which are -(ideally) already *machine-readable* (although they may still need -transformation to fit into your database/format of choice). These include: - -* __Data downloads__: some web sites provide their content in structured forms. - Some names for data formats include Excel, CSV, RSS, XML and JSON. -* APIs: many major sources and distributors of content provide software - developers with a [web-based Application Programming - Interface](https://en.wikipedia.org/wiki/Web_API) to query and download their - often dynamic data in a structured format. APIs tend to differ from each - other in design, so some new development tends to be required to get data - from each one. Most require some authentication like a username and password - before access is granted (even when it is granted for free). -* __semantic web knowledge bases__: web sites providing structured knowledge, of - which [WikiData](http://wikidata.org) is a good example. These tend to be - structured as [OWL](https://en.wikipedia.org/wiki/Web_Ontology_Language) - ontologies, and can often be queried through - [SPARQL](https://en.wikipedia.org/wiki/SPARQL) endpoints or downloaded as - large data collections. -* __microformats__: some web sites may overlay their visual content with [specially - schematised labels](http://schema.org) for certain kinds of knowledge, such - as publication metadata (title, author, publication date), contact details or - product reviews. While web sites using microformats are by far in the - minority, where they are, specialised extraction tools do not need to be - developed. - -Before scraping a web site, it is always a good idea to check whether a -structured representation of the same content is provided. -Choose the right (i.e. the easiest) tool for the job. - -- Check whether or not you can easily _copy and paste data_ from a site into Excel or Google Sheets. This might be quicker than scraping. -- Check if the site or service _already provides an API_ to extract structured data. If it does, that will be a much more efficient and effective pathway. Good examples are the -[Facebook API](https://developers.facebook.com/tools/explorer/), the [Twitter APIs](https://dev.twitter.com/rest/public) or the [YouTube comments API](https://developers.google.com/youtube/v3/docs/commentThreads/list). -- For much larger needs, _Freedom of Information requests_ can be useful. Be specific about the formats required for the data you want. - -### Not web scraping: information extraction - -We are also -not including tasks that find content in free text. Such tasks, known -by the name *information extraction* may seek a list of all organisations -mentioned, or may try to identify mentions of business acquisitions and the -companies involved from text. -Related technology in text interpretation may try to determine -if an author used positive or negative language. Related technology in -information extraction may aggregate content found in differently -formatted tables across many web sites (or academic papers). - -These are real technologies, but not within scope of web scraping. In contrast -to these, web scraping usually expects content to be consistently formatted, -and extractable with very high precision (the extracted content is very clean -of errors) and recall (the extracted content is complete from the pages -visited). - -# Example: a database of UN Security Council Resolutions - -In this lesson, we will extract the history of resolutions made by the United -Nations Security Council (UNSC) as [found on its web -site](http://www.un.org/en/sc/documents/resolutions/). Each year from 1946 to -now has its own page on which resolutions from that year are posted in a -tabular form. Our task is to build a system which extracts a spreadsheet in -comma-delimited (CSV) format with rows like: +## Example: scraping government websites for contact addresses -~~~ -date,symbol,title,url -… -2010,S/RES/1942 (2010),Côte d'Ivoire,http://www.un.org/en/ga/search/view_doc.asp?symbol=S/RES/1942(2010) -2010,S/RES/1941 (2010),Sierra Leone,http://www.un.org/en/ga/search/view_doc.asp?symbol=S/RES/1941(2010) -… -1962,S/RES/174 (1962),Admission of new Members to the UN: Jamaica,http://www.un.org/en/ga/search/view_doc.asp?symbol=S/RES/174(1962) -… -~~~ -{: .output} +In this lesson, the examples that we will use all involve extracting contact information +from government websites listing the members of various constituencies. A practical example +of why this information would be useful could be an advocacy group wishing to making it easier +for citizens to contact their representatives about a particular issue. -This comma-delimited format lists each resolution on a separate line, with the -fields "date", "symbol", "title" and "url" separated by commas (","). +Let's start by looking at the current list of members of the Canadian parliament, which is available +on the [Parliament of Canada website](http://www.parl.gc.ca/Parliamentarians/en/members). -Looking at the web site, it appears quite close to this format already: each page, such as -[the one for 1962](http://www.un.org/en/sc/documents/resolutions/1962.shtml) -includes a table with a row for each resolution. +This is how this page appears in November 2016: -![Screenshot of the UNSC resolutions from 1962]({{ page.root }}/fig/unscr-fragment.png) +![Screenshot of the Parliament of Canada website]({{ page.root }}/fig/canparl.png) -The last row excerpted above (and also shown in the intended CSV output) is -encoded in HTML as: +There are several features (circled in the image above) that make the data on this page easier to work with. +The search, reorder, refine features and display modes hint that the data is actually stored in a (structured) +database before being displayed on this page. The data can be readily downloaded as a Comma-Separated Values (CSV) +file or XML, which allows anyone to load this data in their own database, spreadsheet or computer program to +reuse it. + +Even though the information displayed in the view above isn't labeled, a person visiting this site with some +knowledge of Canadian geography and politics is quickly able to figure out what information pertains to the +name of the politicians, the geographical area or the political party they represent. This is because human +beings are usually good at using context and prior knowledge to quickly categorize information. + +Computers, on the other hand, can't do this unless we provide them with more information. +Fortunately, if we look at the source HTML code of this page, we see that the information displayed is actually +organized inside labeled elements: ~~~ -… - - S/RES/174 (1962) - Admission of new Members to the UN: Jamaica - -… +(...) +
+ + Photo - Ziad Aboultaif - Click to open the Member of Parliament profile +
+ + Ziad + Aboultaif +
+
+
+
Conservative
+
Edmonton Manning
+
Alberta
+
+(...) ~~~ {: .output} -When looking at such pages, we can see that the columns aren't labelled. We are -expected to understand that the left column is some reference identifier or -symbol for the resolution, and the right column is a title or topic. Thus we -interpret the visual presentation of the data, relying on our background -knowledge. When we do not care to navigate around the site, we similarly are -able to identify the navigation menus on the left and at the top and ignore it. -Computers cannot make such interpretations unassisted. +Thanks to these labels, we could relatively easily instruct a computer to look for all parliamentarians from +Alberta and list their names and caucus information. -> ## Structured vs. unstructured data +> ## Structured vs unstructured data > > When presented with information, human beings are good at quickly categorizing it and extracting the data > that they are interested in. For example, when we look at a magazine rack, provided the titles are written > in a script that we are able to read, we can rapidly figure out the titles of the magazines, the stories they -> contain, the language they are written in, etc. and we can probably also easily organize them by topic, +> contain, the language they are written in, etc. and we can probably also easily organize them by topic, > recognize those that are aimed at children, or even whether they lean toward a particular end of the > political spectrum. Computers have a much harder time making sense of such _unstructured_ data unless > we specifically tell them what elements data is made of, for example by adding labels such as @@ -194,68 +117,68 @@ Computers cannot make such interpretations unassisted. > {: .callout} -## The task - -Our task is to merge the data from all the UNSC resolution pages into a single, -consistent and machine-readable format that will allow us to: - -* count and plot how many resolutions were passed each year -* count and plot how many pertained UN membership vs. security motions -* search for resolutions pertaining to particular countries' names -* divide the statistics by geopolitical region (e.g. South America vs. East Asia) -* periodically update our database as long as the web site maintains its current format - -(We could potentially further enrich the database with the full digitised text -of the resolutions, but this would require performing [Optical Character -Recognition](http://en.wikipedia.org/wiki/Optical_character_recognition) since -most of the resolutions are presented as PDFs of scanned paper prints. We -leave this as a further exercise for the student!) - -***How can we do this?*** - -We could try copy-pasting the table for each year into a spreadsheet, but this can -quickly become impractical when faced with a large number of years, and wanting -to collect updates frequently. Another resource may have a multitude of pages (monthly -or weekly records, perhaps) for similar archives. - -Fortunately, there are tools and techniques to automate at least part of the -process, known as _web scraping_. -Web scraping typically targets _one web site at a -time_ to extract unstructured information and put it in a structured form for reuse. - -Assuming that many other sites, or UN agencies, archive reports and resolutions -through similar web pages, the same techniques (although perhaps not the same -exact piece of software) can be used to extract their data. - -> ## Scraping robustly -> This is but one instance of web scraping. It is interesting because the data is -> apparently not already contained in a database on the UNSC web site. When we -> come to scrape it, we will identify a number of __quirks and inconsistencies__ that -> are endemic to manually edited sites. However, quirks may also occur in web sites backed by -> databases. For instance, there may be multiple types of product and each -> is presented differently; or some fields appear and disappear depending on the -> object; or you want to be able to periodically update the scraped data, but the web -> site changes its design altogether. Among the major challenges in designing a -> web scraper is building a system that is __robust to variation__, or where it is -> easy to __diagnose that the web scraper has broken__. -{: .callout} +Let's look now at the current list of members for the [UK House of Commons](https://www.parliament.uk/mps-lords-and-offices/mps/). -In this lesson, we will continue exploring techniques to extract -the information in the UNSC resolutions archive. But before we launch into web scraping proper, we need to look -a bit closer at how information is organized within an HTML document and how to build queries to access -a specific subset of that information. +![Screenshot of the UK House of Commons website]({{ page.root }}/fig/ukparl.png) + +This page also displays a list of names, political and geographical affiliation. There is a search box and +a filter option, but no obvious way to download this information and reuse it. + +Here is the code for this page: -## Tools and techniques for scraping +~~~ +(...) + + + (...) + + + + + (...) + +
Aberavon + Kinnock, Stephen(Labour) +
+(...) +~~~ +{: .output} + +We see that this data has been structured for displaying purposes (it is arranged in rows inside +a table) but the different elements of information are not clearly labeled. -A number of tools have been developed to help build web scrapers. These differ -in capability or expressiveness, and in their usability without programming. -Several of the available tools are associated with services which host the -scraper and run it for a fee. -Our workshop emphasises core technologies and concepts for spidering and -for extracting content from page structure, while trying to focus on -free open-source tools. +What if we wanted to download this dataset and, for example, compare it with the Canadian list of MPs +to analyze gender representation, or the representation of political forces in the two groups? +We could try copy-pasting the entire table into a spreadsheet or even manually +copy-pasting the names and parties in another document, but this can quickly become impractical when +faced with a large set of data. What if we wanted to collect this information for every country that +has a parliamentary system? + +Fortunately, there are tools to automate at least part of the process. This technique is called +_web scraping_. + +> +> "Web scraping (web harvesting or web data extraction) is a computer software technique of +> extracting information from websites." +> (Source: [Wikipedia](https://en.wikipedia.org/wiki/Web_scraping)) +> + +This technique is closely related to _web indexing_ which is what search engines like Google do +to build the database that is queried when users are searching. The difference is that web indexing +(using tools typically called "bots" or "crawlers") aims to visit _all_ web sites recursively, +following all links (unless blocked), index all data and store the result in a database and repeat +every so often to keep their index current. + +Web scraping, on the other hand, is a more focused technique, typically targeting one web site at a +time to extract unstructured information and put it in a structured form for reuse. + +In this lesson, we will continue exploring the examples above and try different techniques to extract +the information they contain. But before we launch into web scraping proper, we need to look +a bit closer at how information is organized in an HTML document and how to build queries to access +a specific subset of that information. # References * [Web Scraping (Wikipedia)](https://en.wikipedia.org/wiki/Web_scraping) * [The Data Journalism Handbook: Getting Data from the Web](http://datajournalismhandbook.org/1.0/en/getting_data_3.html) + diff --git a/_episodes/02-csssel.md b/_episodes/02-csssel.md deleted file mode 100644 index 032cfb2..0000000 --- a/_episodes/02-csssel.md +++ /dev/null @@ -1,656 +0,0 @@ ---- -title: "Selecting content on a web page with CSS selectors" -teaching: 30 -exercises: 20 -questions: -- "How can I select a specific element on web page?" -- "What is a CSS Selector and how can I use it?" -objectives: -- "Introduce CSS Selectors" -- "Explain the structure of an XML or HTML document" -- "Explain how to view the underlying HTML content of a web page in a browser" -- "Explain how to run CSS Selector queries in a browser" -- "Introduce the CSS Selector syntax" -- "Use the CSS Selector syntax to select elements on this web page" -keypoints: -- "XML and HTML are markup languages. They provide structure to documents." -- "XML and HTML documents are made out of nodes, which form a hierarchy." -- "The hierarchy of nodes inside a document is called the node tree." -- "Relationships between nodes are: parent, child, descendant, sibling." -- "CSS selectors are constructed by specifying properties of the targets combined with properties of their context." -- "IDs, classes and tag names should be preferred as properties for extraction." -- "CSS selectors can be evaluated using the `document.querySelectorAll()` function." ---- -Before we delve into web scraping proper, we will first spend some time introducing -some of the techniques that are required to indicate exactly what should be -extracted from the web pages we aim to scrape. - -# Matching patterns - -A key part of web scraping is describing to the computer how it should find the -content you seek. Several tools have been designed for succinctly describing -patterns that can be matched to document structure so that selected content can -be efficiently extracted. The most important for web scraping are: - -* Regular expression: These select portions of strings of characters (e.g. - text, a URL). They can be used to identify, for instance, typical forms of - date (`yyyy-mm-dd`, `d/m/yyyy`, etc.) or of an email address, or whether a URL is - the kind of URL you want to download and scrape. -* XPath: These specify parts of a tree-structured document, be it XML or HTML. - They can be very specific about which nodes to include or exclude. -* CSS selectors: These serve a similar function to XPath, in selecting parts of - an HTML document, but were designed for web development (for applying styles - such as colour to parts of a document). As such, they are more popular, but - are limited in what they can express relative to XPath. Every CSS selector - can be translated into an equivalent XPath expression, but not vice-versa. - -We focus on CSS selectors for their simplicity, although a parallel [lesson covering XPath]({{page.root}}/xpath) is available. - -## Markup Languages - -When you view a page in your web browser, this usually involves downloading content encoded in HTML. The browser then renders this content visually. - -XML and HTML are closely related _markup languages_. -In fact HTML is like a dialect of XML specialised for structuring web pages. -This means that they use a set of tags or rules to organise and provide -information about their content. This structure helps to automate processing, editing, formatting, -displaying, printing, etc. that information. - -XML documents store data in plain text format, making it relatively easy to harness XML data without very specialised knowledge or tools. -But the structure of XML demands techniques for pinpointing content within it. - -> ## XML and HTML -> -> HTML and XML have a very similar structure, which is why XPath and CSS selectors can be used almost interchangeably to -> navigate both HTML and XML documents. -> -{: .callout} - -## Structure of a marked-up document - -An XML document follows basic syntax rules: - -* An XML document is structured using _nodes_, which include element nodes, attribute nodes and text nodes. -* XML element nodes must have an opening and closing tag, e.g. `` opening tag and `` closing tag. Everything between those tags is contained within the element. -* XML _tag names_ are case sensitive, e.g. `` does not equal ``. -* Within an element there may be other _child elements_. These must be properly nested (every child element that is opened must also be closed): - -~~~ - - Purina - -
12 Cat Way, Boise, Idaho, 21341
-
- 2019-10-01 -
-~~~ -{: .output} -* Within an element there may also be text nodes. `Purina` and `2019-10-01` are both text nodes. Another text node contains the white space between `` and ``. -* XML attribute nodes (like `type` in `` above) have a name, and a value that must be quoted. - -Note that there may be multiple elements with a particular tag name: -~~~ - - ... - ... - ... - -~~~ -{: .output} - -Some of these rules are relaxed in HTML: - -* tag and attribute names are case insensitive (`` equals ``) -* some elements are closed automatically (e.g. `` cannot contain any other elements or text) -* attribute values do not need to be quoted - -HTML can nonetheless be represented as a tree of nodes. - -## Tree structure - -A popular way to represent the structure of an XML or HTML document is the _node tree_, where each rectangle is a node: - -![XML node tree]({{ page.root }}/fig/catfood-tree.png) - -We use the terms _parent_, _child_ and _sibling_ to describe the hierarchical relationships between nodes: - -* The top node is called the *root* (or *root node*). `` is the root here. -* Every node has exactly one *parent*, except the root (which has no parent). The `` node's parent is the `` node. -* An element (one kind of node) node can have zero, one or several *children*. Attribute and text nodes have no children. `
` has two child nodes, but no child elements. -* *Siblings* are nodes with the same parent. -* A node's children and its children's children, etc., are called its *descendants*. Similarly, a node's parent and its parent's parent, etc., are called its ancestors. Except for the root node, all nodes are descendants of the root node. - -## Common HTML elements - -In HTML, the tag names aren't usually as specific in their semantics as `manufacturer` or `address`. Here are some of the most common HTML elements: - -| Tag name | What it is used for | -|-----------------|-----------------------------------------| -| `p` | A paragraph of text | -| `h1` | A top-level heading | -| `h2`, `h3`, ... | A lower-level heading | -| `li` | An item in a list | -| `img` | An image | -| `tr` | A row in a table | -| `td` | A cell in a table | -| `a` | A link | -| `div` | A block of space on the page (generic) | -| `span` | A portion of text on the page (generic) | -| `meta` | Information about the page that is not shown | - -See the [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) for a full listing. - -# CSS Selectors - -Using CSS Selectors is similar to using advanced search in a library catalogue, where the structured nature of bibliographic information allows us to specify which metadata fields to query. For example, if we want to find books *about* Shakespeare but not works *by* him, we can limit our search to the `subject` field only. - -When we use CSS Selectors, we do not need to know in advance what the content we want looks like (as we might with regular expressions, where specify the pattern of the data). Since HTML documents are structured as a network of nodes, CSS Selectors make use of that structure to navigate through the nodes and select the data we want. We just need to know which nodes in an HTML file contain what we want to extract. - -A CSS Selector (as with an XPath selector) is, somewhat like a search query, a short piece of text that describes which nodes are sought. A CSS Selector can be *evaluated* on a document (or on each of many documents): the evaluator follows the instructions implied by the selector, finds the sought nodes in the document and returns them to the program that requested them. - -Here are some examples of the sort of things one can express with CSS selectors (and XPath for comparison) based on the document fragments above: - -| CSS selector | XPath expression | Description | -|----------------------|----------------------------|-------------| -| `address` | `//address` | Get every `address` element (and its contents) in the document | -| `catfood address` | `//catfood//address` | Get every `address` element somewhere inside a `catfood` element | -| `catfood[type=basic]`| `//catfood[@type='basic']` | Get every `catfood` element that has a `type` attribute with value "basic" | - -CSS selectors can only retrieve element nodes. Text and attributes need to be extracted outside of the CSS selector expression. - -## Finding elements with CSS selectors - -CSS selector expressions consist of *basic selectors* which describe the properties of elements targeted for extraction (e.g. _has tag name `address`_ is described as `address`). Sometimes we only want an element extracted if it appears in a particular context (e.g. _appears somewhere inside a `` element_). We can describe valid contexts for the extracted elements by forming a basic selector for the context (`catfood`) and combining the selector for the context and the target (`catfood address`). - -Common basic selectors are: - -| Basic selector | Kind | Description | -|---------------------|--------------------|-------------------------------------------------------------------------------| -| `*` | Universal selector | Matches all elements | -| `name` | Type selector | For any given _name_, matches all elements with that tag name. | -| `.name` | Class selector | Matches all elements whose `class` attribute includes the word _name_. | -| `#name` | ID selector | Matches all elements whose `id` attribute is exactly _name_. | -| `[attr]` | Attribute selector | Matches all elements having an attribute named _attr_. | -| `[attr=value]` | Attribute selector | Matches all elements having an attribute named _attr_ whose value is _value_. | -| `[attr="value"]` | Attribute selector | Same. With quotes around _value_, it may contain spaces and punctuation. | -| `:nth-child(n)` | Pseudo-class | Matches all elements that are child number _n_ (ignoring text and attribute nodes) under their parent. | -| `:nth-of-type(n)` | Pseudo-class | Matches all elements that are child number _n_ of that same tag name under their parent. | - -To express that an element must satisfy multiple properties, simply join them _without a space in between_. The example of `catfood[type=basic]` above combines a type selector and an attribute selector. - -Required context can be expressed by combining a context selector (_C_) and a target selector (_T_) with special *combinators*: - -| Selector combination | Name | Description | -|--------------------------|------------------|----------------------------------------------------------------------| -| `C > T` | Child | Only match _T_ when it is a child of an element matched by _C_. | -| `C T` | Descendant | Only match _T_ when it is a descendant of an element matched by _C_. | -| `C + T` | Adjacent sibling | Only match _T_ when it immediately follows _C_ as _C_'s sibling. | -| `C ~ T` | Sibling | Only match _T_ when it is a sibling of _C_ (regardless of order). | - -Note that _C_ can be an arbitrarily complex selector, perhaps combining many basic selectors. _T_ is a basic selector for the target. - -> ## Selecting the `
` -> -> We repeat the above example document fragment: -> -> ~~~ -> -> Purina -> ->
12 Cat Way, Boise, Idaho, 21341
->
-> 2019-10-01 ->
-> ~~~ -> {: .output} -> -> With respect to this example, **explain why** each selector matches or does not match the `
` node: -> -> | Selector | Matches the `
`? | -> |----------------------------------------|--------------------------| -> | `address` | Yes | -> | `Address` | Yes | -> | `catfood address` | Yes | -> | `catfood[type=basic] address` | Yes | -> | `catfood[type=BASIC] address` | No! | -> | `catfood[type=premium] address` | No | -> | `catfood[type="basic"] address` | Yes | -> | `catfood > address` | No | -> | `catfood > * > address` | Yes | -> | `catfood > :nth-child(2) > address` | Yes | -> | `catfood > :nth-child(3) > address` | No | -> | `catfood > :nth-of-type(1) > address` | Yes | -> | `catfood > :nth-of-type(2) > address` | No | -> | `catfood > manufacturer + * > address` | Yes | -> | `catfood > date + * > address` | No | -> | `catfood > date ~ * > address` | Yes | -> | `catfood address.USA` | Yes | -> | `catfood address.usa` | Yes | -> | `catfood address[class=USA]` | Yes | -> | `catfood address[class=usa]` | No! | -> | `catfood address."usa"` | No (invalid) | -> | `"catfood" address` | No (invalid) | -> -{: .challenge} - -Refer to the [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) for a full listing of CSS selectors. - -> ## Drill common CSS selectors using the CSS Diner -> -> The previous challenge illustrated understanding selectors, but it takes more practice to confidently compose and alter CSS selectors. -> -> The [CSS Diner](https://flukeout.github.io/) is a fun way to practice writing CSS selectors. It shows XML code, with a corresponding display of food, and challenges you to select certain food, and only that food, by writing an appropriate CSS selector. In the pane on the right, it teaches you about expression syntax relevant to the current challenge. -> -{: .challenge} - -## Evaluating CSS selectors in a web browser - -We will use the HTML code that describes this very page you are reading as an example. By default, a web browser -interprets the HTML code to determine how to present to the various elements of a document, and the code is -invisible. To make the underlying code visible, all browsers have a function to display the raw HTML content of -a web page. - -> ## Display the source of this page -> Using your favourite browser, display the HTML source code of this page. -> -> Tip: in most browsers, all you have to do is do a right-click anywhere on the page and select the "View Page Source" -> option ("Show Page Source" in Safari). -> -> Another tab should open with the raw HTML that makes this page. See if you can locate its various elements, and -> this challenge box in particular. -> -> Another way to view the HTML node structure of the page is to right click the page and choose "Inspect" or "Inspect Element". Note: this can differ from the HTML structure in the source code, because of how the browser processes the source HTML. -> -{: .challenge} - -> ## Developer tools in the Safari browser -> -> If you are using Safari, you must first turn on the "Develop" menu in order to view the page source, and use the -> functions that we will use later in this section. To do so, navigate to Safari > Preferences and in the Advanced tab -> select the "Show Develop in menu bar" option. -> -{: .callout} - -The HTML structure of the page you are currently reading looks something like this (most text and elements have -been removed for clarity): - -~~~ - - - - (...) - {{page.title}} - - - (...) - - -~~~ -{: .output} - -We can see from the source code that the title of this page is in a `title` element that is itself inside the -`head` element, which is itself inside an `html` element that contains the entire content of the page. - -Say we wanted to tell a web scraper to look for the title of this page, we would use this information to indicate the -_path_ the scraper would need to follow as it navigates through the HTML content of the page to reach the `title` -element. CSS selectors allow us to do that. - -We can evaluate CSS selectors directly from within all major modern browsers, by using the built-in JavaScript console. - -> ## Display the console in your browser -> -> * In Chrome, use the *View > Developer > JavaScript Console* menu item. -> * In Firefox, use to the *Tools > Web Developer > Web Console* menu item. -> * In Safari, use the *Develop > Show Error Console* menu item. If your Safari browser doesn't have a Develop menu, -> you must first enable this option in the Preferences, see above. -> -{: .callout} - -Here is how the console looks like in the Firefox browser: - -![JavaScript console in Firefox]({{ page.root }}/fig/firefox-console.png) - -For now, don't worry too much about error messages if you see any in the console when you open it. The console -should display a _prompt_ with a `>` character (`»` in Firefox) inviting you to type commands. - -The syntax to evaluate a CSS Selector on the current page within the JavaScript console is `document.querySelectorAll("SELECTOR")`. For example: - -~~~ -document.querySelectorAll("html > head > title") -~~~ -{: .source} - -If you enter this and press enter, it should return something similar to - -``` -NodeList [ ] -``` -{: .output} - -The output can vary slightly based on the browser you are using. For example, Chrome will show `[` where Firefox shows `NodeList [`. Both these symbols indicate that `querySelectorAll` returned a list of elements, even though there is only one `<title>` element in that list. We can extract the individual element by adding `[0]` to get the first element from the list: - -~~~ -document.querySelectorAll("html > head > title")[0] -~~~ -{: .source} - -Adding `.innerText` will retrieve the text from within the returned element. (Note that this `.innerText` notation looks deceptively similar to the class selector notation.) - -~~~ -document.querySelectorAll("html > head > title")[0].innerText -~~~ -{: .source} - -Output: -~~~ -"{{page.title}}" -~~~ -{: .output} - -Let's look closer at this CSS selector: `html > head > title`. It can be thought of instructions for the web browser to find the `<title>` element. The `<html>` node is the root of an HTML document. We told the browser to: - -|-----------------|:-------------| -| `html` | ... navigate to the `html` node ... | -| `> head` | ... then to its child with tag name `head` ... | -| `> title` | ... then to its child with tag name `title` ... | - -Using this syntax, CSS selectors allow us to specify the exact _path_ to a set of nodes. - -> ## Select the blockquote titled "Overview" -> Write a CSS selector that selects the "Overview" box above, using a path of children from the root node, and try running it in the console. -> -> > ## Solution -> > -> > ~~~ -> > document.querySelectorAll('html > body > div > blockquote:nth-of-type(1)') -> > ~~~ -> > {: .source} -> > -> > should produce something similar to -> > -> > ~~~ -> > <- NodeList [ <blockquote.objectives> ] -> > ~~~ -> > {: .output} -> > -> > Alternatives include: -> > -> > * `document.querySelectorAll('html > body > div > blockquote')[0]` -> > * `document.querySelectorAll('html > body > div > blockquote.objectives')` -> > -> {: .solution} -{: .challenge} - -## Nested elements - -If we want to select all the `blockquote` elements visible on this page, we can write: - -~~~ -document.querySelectorAll('html > body > div > blockquote') -~~~ -{: .source} - -This produces an array of objects along the lines of: - -~~~ -<- Array [ <blockquote.objectives>, <blockquote.callout>, <blockquote.callout>, <blockquote.challenge>, <blockquote.callout>, <blockquote.callout>, <blockquote.challenge>, <blockquote.challenge>, <blockquote.challenge>, <blockquote.keypoints> ] -~~~ -{: .output} - -This selects all the `blockquote` elements that are children of the container `<div>`. If we want instead to select _all_ -`blockquote` elements in this document, we can use: - -~~~ -document.querySelectorAll('blockquote') -~~~ -{: .source} - -This produces a longer array of objects: - -~~~ -<- Array [ <blockquote.objectives>, <blockquote.callout>, <blockquote.callout>, <blockquote.challenge>, <blockquote.callout>, <blockquote.callout>, <blockquote.challenge>, <blockquote.solution>, <blockquote.challenge>, <blockquote.solution>, … ] -~~~ -{: .output} - -> ## Why is the second array longer? -> If you look closely into the array that is returned by the `blockquote` selector above, -> you should see that it contains objects like `<blockquote.solution>` that were not -> included in the results of the first query. Why is this so? -> -> Tip: Look at the source code and see how the challenges and solutions elements are -> organised. -> -{: .challenge} - -## Class and ID filtering - -We can use the `class` attribute of certain elements to filter down results. For example, looking -at the list of `blockquote` elements returned by the previous query, and by looking at this page's -source, we can see that the blockquote elements on this page have different classes -(challenge, solution, callout, etc.). - -To refine the above query to get all the `blockquote` elements of the `challenge` class, we can type - -~~~ -document.querySelectorAll('blockquote.challenge') -~~~ -{: .source} - -which returns - -~~~ -<- Array [ <blockquote.challenge>, <blockquote.challenge>, <blockquote.challenge>, <blockquote.challenge> ] -~~~ -{: .output} - -In principle, `id` attributes in HTML are unique on a page. This means that if you know the `id` -of the element you are looking for, you should be able to construct an expression that looks for this value -without having to worry about where in the node tree the target element is located. - -> ## Select the "Matching patterns" title by ID -> Sometimes we can select an element by the order in which it appears, using selectors like -> `:nth-child(n)` and `:nth-of-type(n)`. But what if we want to match a particular element -> irrespective of order? Is there a different attribute that allows us to uniquely identify -> that title element? -> -> Write a CSS selector which extracts the "Matching patterns" title by its ID. -> -> Tips: -> -> * Look at the source of the page or use the "Inspect element" function of your browser to see what -> other information would enable us to uniquely identify that element. -> * The syntax for selecting an element like `<div id="mytarget">` is `#mytarget`. -> -> > ## Solution -> > -> > ~~~ -> > document.querySelectorAll("#matching-patterns") -> > ~~~ -> > {: .source} -> > -> > should produce something similar to -> > -> > ~~~ -> > <- Array [ <h1#matching-patterns> ] -> > ~~~ -> > {: .output} -> > -> {: .solution} -{: .challenge} - -> ## What makes a good selector? -> Essential to web scraping is being able to select the set of elements you want, without selecting any additional elements. -> Many web scrapers are run periodically on web sites with changing data. One challenge is that the structure of that page -> can also change or vary across items being scraped. -> -> A good selector may be characterised by: -> -> * being specific: not capturing things you don't need -> * being robust to change: the selector should ideally still work if some basic things about the page structure change (e.g. an image is inserted; a field, such as an author's name, is absent). If the selector breaks due to change it is _better for it to extract nothing_ than to extract the wrong thing as it is easy to monitor how many selectors come back empty. -> * being easy to read: if things are going to break or change, readable selectors help to avoid redesigning the selector from scratch. -> -> All of these characteristics suggest preferring IDs and classes (and perhaps other attributes) where possible, and being judicious in choosing between a child or a descendant combinator. -{: .callout} - - -Oftentimes, the elements we are looking for on a page have no ID attribute or -other uniquely identifying features, so the next best thing is to aim for -neighboring elements that we can identify more easily and then use sibling -combinators to get from those easy-to-identify elements to the target elements. - -> ## Select this challenge box text -> Using a CSS selector in the JavaScript console of your browser, select this paragraph and the rest of the -> contents of this challenge box. -> -> Tips: -> -> * The syntax to select the siblings of context elements is `context + target` -> * Since you don't have any basic selector attributes for the target, you might use the universal selector (`*`) -> -> > ## Solution -> > Let's have a look at the HTML code of this page, around this challenge box (using the "View Source" or "Inspect Element" option) -> > in our browser). The code looks something like this: -> > -> > ~~~ -> > <!doctype html> -> > <html lang="en"> -> > <head> -> > (...) -> > </head> -> > <body> -> > <div class="container"> -> > (...) -> > <blockquote class="challenge"> -> > <h2 id="select-this-challenge-box-text">Select this challenge box text</h2> -> > <p>Using an CSS selector in the JavaScript console of your browser...</p> -> > (...) -> > </blockquote> -> > (...) -> > </div> -> > </body> -> > </html> -> > ~~~ -> > {: .output} -> > -> > We know that the `id` attribute should be unique, so we can use this to select the `h2` element inside -> > the challenge box: -> > -> > ~~~ -> > document.querySelectorAll("#select-this-challenge-box-text + *")[0] -> > ~~~ -> > {: .source} -> > -> > This should return something like: -> > -> > ~~~ -> > <- NodeList [ <p>, <p>, <ul>, <p>, <blockquote.solution> ] -> > ~~~ -> > {: .output} -> > -> > Let's walk through that syntax: -> > -> > |-----------------|:-------------| -> > | `document.querySelectorAll("`| This function tells the browser we want it to execute an CSS selector . | -> > | `#...`| Find by ID (anywhere in the document)... | -> > | `+ *`| Get all the siblings of the preceding context | -> > -> > By hovering your mouse cursor over the object returned by your query in the console, your browser may helpfully highlight -> > that object in the document, enabling you to make sure you got the right one: -> > -> > ![Hovering over a resulting node in Firefox]({{ page.root }}/fig/firefox-hover.png) -> {: .solution} -{: .challenge} - -# Advanced `:nth-...` selectors - -We presented the `:nth-child` and `:nth-of-type` selectors, but we only showed that you can place a number inside their parentheses, like `:nth-child(2)`. However, you can put formulas in the parentheses: - -* `:nth-child(2n)` will select all even children -* `:nth-child(2n+1)` will select all odd children -* `:nth-child(3n)` will select every third child -* `:nth-child(n+2)` will select every child except for the first -* `:nth-child(an+b)` for any integers _a_ and _b_ will start selecting the _b_th child and select every _a_th child after that - -`:nth-last-child` and `:nth-last-of-type` parallel the above pseudo-selectors, but their formulas match from last to first, rather than first to last. - -> ## Challenge: formulas in selectors -> 1. Select the headline `<h2>` of every second `<blockquote>` from the body of this page in the browser console. -> 2. Select the headline `<h2>` of all but the first and the last `<blockquote>` from the body of this page in the browser console. -> -> > ## Solution -> > 1. `document.querySelectorAll(".container > blockquote:nth-of-type(2n) > h2")` -> > 2. `document.querySelectorAll(".container > blockquote:nth-of-type(n+2):nth-last-of-type(n+2) > h2")` -> > -> > Confirm that the right number of elements is returned with, for instance: -> > ~~~ -> > all_blockquotes_count = document.querySelectorAll(".container > blockquote > h2").length -> > selected_blockquotes_count = document.querySelectorAll(".container > blockquote:nth-of-type(n+2):nth-last-of-type(n+2) > h2").length -> > all_blockquotes_count - selected_blockquotes_count -> > ~~~ -> > {: .source} -> > Expected result: -> > ~~~ -> > 2 -> > ~~~ -> > {: .output} -> {: .solution} -{: .challenge} - -# Limitations of CSS Selectors - -A key limitation of CSS Selectors (prior to level 4) is that you cannot generally select an element based on _what it contains_. (This limitation my derive from the assumption that the author of a CSS selector was usually able to modify the markup to engineer simple selectors. This may be a reasonable assumption when selectors are used for styling a page or making it interactive.) - -For example, using CSS3 selectors alone we cannot select a challenge box on the basis of its title `<h2>` having a specific ID. -CSS Level 4, which is (as of June 2017) a draft and not implemented in any major web browser may allow for: - -~~~ -/* May work in the future: */ -document.querySelectorAll("blockquote.challenge > :matches(#select-this-challenge-box-text)") -~~~ -{: .source} - -Operating within these limitations, we are sometimes forced to use selectors only as an initial set of extractions, and then to navigate their surrounds with a general-purpose programming language. To extract the challenge box titled "Select this challenge box" in the web browser console, we can use `parentNode` in JavaScript: - -~~~ -document.querySelectorAll("#select-this-challenge-box-text")[0].parentNode -~~~ -{: .source} - -~~~ -<- <blockquote class="challenge">...</blockquote> -~~~ -{: .output} - -XPath is able to select on the basis of descendants. Unlike CSS it is also able to: - -* select just the first (or any other offset) of a set of elements. (`:nth-child` and `:nth-of-type` can only select the first with respect to a parent.) -* select elements on the basis of the text they contain. -* return the value of an attribute on a matched element. -* return the text contained by matched elements. - -These too require a general-purpose programming language to solve when using CSS selectors. - -# Tools to help composing CSS selectors - -Viewing the HTML source of a page may help you design an appropriate selector. Another tool available to you is the "Inspector" or "Elements" tab of the developer tools in your browser. Right clicking an element on the displayed page and choosing "Inspect Element" will take you straight to that element's HTML in its context. Then: - -* Parts of the HTML can be shown or hidden by clicking the triangles on the left. -* Hovering your mouse cursor over an HTML element will highlight its position in the document. -* Above or below the HTML (depeding on web browser) you can see the list of elements (their tag names, IDs and classes) from the root to the selected element shown as basic CSS selectors. - -Browser extensions such as [Selector Gadget](http://selectorgadget.com) or [CSS Selector Helper for Chrome](https://chrome.google.com/webstore/detail/gddgceinofapfodcekopkjjelkbjodin) may further assist in developing a specific selector. - -> ## Source vs computed DOM -> What you see in the element / DOM inspector, and what `document.querySelectorAll` evaluates CSS selectors on, need not be identical to what you see in View Source. The DOM (Document Object Model) is the version of the node tree computed by the browser after reading the HTML source, but also after running any _scripts_ associated with the page. These scripts can modify the computed node tree in arbitrary ways, including loading content from other places and changing the page in response to interaction. Another reason the DOM may differ from the raw HTML is if the raw HTML is invalid: the web browser (or any HTML parser) needs to make interpretive decisions about where a missing closing tag of an element should be placed, or whether a closing tag lacking an opening tag like (`</p>`) should be treated as empty (`<p></p>`) or deleted altogether. -> -> Thus CSS selectors may give different results on the computed DOM than on the original HTML source. -> -> Web scraping has traditionally been performed on the HTML source. Some scraper tools instead incorporate a _web driver_ (basically a web browser with a computer operating it rather than a human) which runs all appropriate scripts and can even simulate interaction with the page. -{: .callout} - -# References - -* [W3Schools: CSS Selectors](https://www.w3schools.com/cssref/css_selectors.asp) -* [W3Schools: HTML elements](https://www.w3schools.com/html/html_elements.asp) -* [W3Schools: JavaScript HTML DOM Navigation](http://www.w3schools.com/js/js_htmldom_navigation.asp) -* [Chrome devtools overview](https://developer.chrome.com/devtools) diff --git a/_extras/xpath.md b/_episodes/02-xpath.md old mode 100644 new mode 100755 similarity index 64% rename from _extras/xpath.md rename to _episodes/02-xpath.md index 4275ab1..21c527b --- a/_extras/xpath.md +++ b/_episodes/02-xpath.md @@ -1,7 +1,5 @@ --- title: "Selecting content on a web page with XPath" -layout: page -permalink: /xpath/ teaching: 30 exercises: 15 questions: @@ -30,38 +28,18 @@ The material in this section was adapted from the [XPath and XQuery Tutorial](ht written by [Kim Pham](https://github.com/kimpham54) ([@tolloid](https://twitter.com/tolloid)) for the July 2016 [Library Carpentry workshop](https://code4libtoronto.github.io/2016-07-28-librarycarpentry/) in Toronto. -# Matching patterns - -A key part of web scraping is describing to the computer how it should find the -content you seek. Several tools have been designed for succinctly describing -patterns that can be matched to document structure so that selected content can -be efficiently extracted. The most important for web scraping are: - -* Regular expression: These specify portions of strings of characters (e.g. - text, a URL). They can be used to identify, for instance, typical forms of - date (yyyy-mm-dd, d/m/yyyy, etc.) or of an email address, or whether a URL is - the kind of URL you want to download and scrape. -* XPath: These specify parts of a tree-structured document, be it XML or HTML. - They can be very specific about which nodes to include or exclude. -* CSS selectors: These serve a similar function to XPath, in selecting parts of - an HTML document, but were designed for web development (for applying styles - such as colour to parts of a document) and so are more commonly known, but - also limited in what they can express relative to XPath. Every CSS selector - can be translated into an equivalent XPath expression. - +# Introduction XPath (which stands for XML Path Language) is an _expression language_ used to specify parts of an XML document. -XPath is often used within technologies aimed at manipulating XML documents, such as XSLT and XQuery. -Later in this lesson we enter XPath expressions into web scraping tools, specifying parts of an HTML document to scrape. +XPath is rarely used on its own, rather it is used within software and languages that are aimed at manipulating +XML documents, such as XSLT, XQuery or the web scraping tools that will be introduced later in this lesson. +XPath can also be used in documents with a structure that is similar to XML, like HTML. ## Markup Languages - -When you view a page in your web browser, this usually involves downloading content encoded in HTML. The browser then renders this content visually. - XML and HTML are _markup languages_. This means that they use a set of tags or rules to organise and provide information about the data they contain. This structure helps to automate processing, editing, formatting, displaying, printing, etc. that information. -XML documents store data in plain text format. This provides a software- and hardware-independent way of storing, +XML documents stores data in plain text format. This provides a software- and hardware-independent way of storing, transporting, and sharing data. XML format is an open format, meant to be software agnostic. You can open an XML document in any text editor and the data it contains will be shown as it is meant to be represented. This allows for exchange between incompatible systems and easier conversion of data. @@ -69,111 +47,77 @@ This allows for exchange between incompatible systems and easier conversion of d > ## XML and HTML > -> Note that HTML and XML have a very similar structure, which is why XPath and CSS selectors can be used almost interchangeably to -> navigate both HTML and XML documents. -> In a loose sense, HTML is like a particular dialect of XML. +> Note that HTML and XML have a very similar structure, which is why XPath can be used almost interchangeably to +> navigate both HTML and XML documents. In fact, starting with HTML5, HTML documents are fully-formed XML documents. +> In a sense, HTML is like a particular dialect of XML. > {: .callout} -## Structure of a marked-up document +XML document follows basic syntax rules: -An XML document follows basic syntax rules: +* An XML document is structured using _nodes_, which include element nodes, attribute nodes and text nodes +* XML element nodes must have an opening and closing tag, e.g. `<catfood>` opening tag and `</catfood>` closing tag +* XML tags are case sensitive, e.g. `<catfood>` does not equal `<catFood>` +* XML elements must be properly nested: -* An XML document is structured using _nodes_, which include element nodes, attribute nodes and text nodes. -* XML element nodes must have an opening and closing tag, e.g. `<catfood>` opening tag and `</catfood>` closing tag. Everything between those tags is contained within the element. -* XML _tag names_ are case sensitive, e.g. `<catfood>` does not equal `<catFood>`. -* Within an element there may be other _child elements_. These must be properly nested (every child element that is opened must also be closed): - -~~~ -<catfood type="basic"> +``` +<catfood> <manufacturer>Purina</manufacturer> - <contact> - <address class="USA"> 12 Cat Way, Boise, Idaho, 21341</address> - </contact> + <address> 12 Cat Way, Boise, Idaho, 21341</address> <date>2019-10-01</date> </catfood> -~~~ -{: .output} -* Within an element there may also be text nodes. `Purina` and `2019-10-01` are both text nodes. Another text node contains the white space between `<catfood>` and `<manufacturer>`. -* XML attribute nodes (like `type` in `<catfood>` above) have a name, and a value that must be quoted - -Note that there may be multiple elements with a particular tag name: -~~~ -<product> - <catfood type="basic"> ... </catfood> - <catfood type="basic"> ... </catfood> - <catfood type="premium"> ... </catfood> -</product> -~~~ -{: .output} - -Some of these rules are relaxed in HTML: - -* tag and attribute names are case insensitive (`<catfood type="basic">` equals `<catFood Type="basic">`) -* some elements are closed automatically (e.g. `<img>` cannot contain any other elements or text) -* attribute values do not need to be quoted - -HTML can nonetheless be represented as a tree of nodes. - -## Tree structure - -A popular way to represent the structure of an XML or HTML document is the _node tree_, where each rectangle is a node: - -![XML node tree]({{ page.root }}/fig/catfood-tree.png) - -We use the terms _parent_, _child_ and _sibling_ to describe the hierarchical relationships between nodes: - -* The top node is called the *root* (or *root node*). -* Every node has exactly one *parent*, except the root (which has no parent). -* An element (one kind of node) node can have zero, one or several *children*. Attribute and text nodes have no children. -* *Siblings* are nodes with the same parent. -* The sequence of connections from node to node is called a *path*. -* A node's children and its children's children, etc., are called its *descendants*. Similarly, a node's parent and its parent's parent, etc., are called its ancestors. - -## Common HTML elements - -In HTML, the tag names aren't usually as specific in their semantics as `manufacturer` or `address`. Here are some of the most common HTML elements: - -| Tag name | What it is used for | -|-----------------|-----------------------------------------| -| `p` | A paragraph of text | -| `h1` | A top-level heading | -| `h2`, `h3`, ... | A lower-level heading | -| `li` | An item in a list | -| `img` | An image | -| `tr` | A row in a table | -| `td` | A cell in a table | -| `a` | A link | -| `div` | A block of space on the page (generic) | -| `span` | A portion of text on the page (generic) | -| `meta` | Information about the page that is not shown | - -See the [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) for a full listing. +``` +* Text nodes (data) are contained inside the opening and closing tags +* XML attribute nodes contain values that must be quoted, e.g. +``` <catfood type="basic"></catfood> ``` # XPath Expressions -Using XPath is similar to using advanced search in a library catalogue, where the structured nature of bibliographic information allows us to specify which metadata fields to query. For example, if we want to find books *about* Shakespeare but not works *by* him, we can limit our search function to the `subject` field only. +XPath is written using expressions, and when these expressions are evaluated on XML documents they return an object +containing the node(s) that you aim to select. Contrary to a flat text document, XML data is structured, as it is +organized in nodes and subnodes. +Therefore, when using XPath, we are not querying raw text or data values like we would so using Regular Expressions, +for example. Instead, XPath makes use of the fact that XML documents are structured and instead navigates through the +node structure to select the data that we are looking for. -When we use XPath, we do not need to know in advance what the content we want looks like (as we would with regular expressions, where we need to know the pattern of the data). Since XML documents are structured as a network of nodes, XPath makes use of that structure to navigate through the nodes to select the data we want. We just need to know in which nodes within an XML file the content we want to find resides. +XPath is typically used to select and compare nodes, not edit them. To manipulate or edit nodes, another language such +as XQuery would be used instead. -An XPath *expression* is, somewhat like a search query, a short piece of text that describes which nodes are sought. An XPath expression can be *evaluated* on a document (or on each of many documents): the XPath evaluator follows the instructions implied by the XPath expression, finds the sought nodes in the document and returns them. - -Here are some examples of the sort of things one can express with CSS selectors (and XPath for comparison) based on the document fragments above above: - -| CSS selector | XPath expression | Description | -|----------------------|----------------------------|-------------| -| `address` | `//address` | Get every `address` element (and its contents) in the document | -| `catfood address` | `//catfood//address` | Get every `address` element somewhere inside a `catfood` element | -| `catfood[type=basic]`| `//catfood[@type='basic']` | Get every `catfood` element that has a `type` element with value "basic" | +> ## XPath assumes _structured_ data +> +> We can think of using XPath as similar to search a library catalogue using the advanced search function. +> In a catalogue, we can take advantage of the fact that bibliographic information has been properly structured +> in the database by specifying which metadata fields we want to query. For example, if we are looking for books +> about Shakespeare but not those written by him, we can use the advanced search function to look for that name +> in the "title" field only. +> +> Contrary to Regular Expressions, this means that we don't have to know in advance what the data we are looking for +> looks like, we just need to know in which node(s) (or fields) it resides. +> +{: .callout} +Now let's start using XPath. ## Navigating through the HTML node tree using XPath -The following images show a node tree: +A popular way to represent the structure of an XML or HTML document is the _node tree_: ![HTML Node Tree](http://www.w3schools.com/js/pic_htmltree.gif) -XPath is built around describing the relationships between its elements: +In an HTML document, everything is a node: + +* The entire document is a document node +* Every HTML element is an element node +* The text inside HTML elements are text nodes + +The nodes in such a tree have a hierarchical relationship to each other. We use the terms _parent_, _child_ and +_sibling_ to describe these relationships: + +* In a node tree, the top node is called the *root* (or *root node*) +* Every node has exactly one *parent*, except the root (which has no parent) +* A node can have zero, one or several *children* +* *Siblings* are nodes with the same parent +* The sequence of connections from node to node is called a *path* ![Node relationships](http://www.w3schools.com/js/pic_navigate.gif) @@ -187,26 +131,21 @@ The most useful path expressions are listed below: | Expression | Description | |-----------------|:-------------| -| `nodename`| Select all nodes with the name "nodename" | -| `/` | A beginning single slash indicates a select from the root node, subsequent slashes indicate selecting a child node from current node | -| `//` | Select direct and indirect child nodes in the document from the current node - this gives us the ability to "skip levels" | -| `.` | Select the current context node | -|`..` | Select the parent of the context node| -|`@` | Select attributes of the context node| -|`[@attribute = 'value']` |Select nodes with a particular attribute value| +| ```nodename```| Select all nodes with the name "nodename" | +| ```/``` | A beginning single slash indicates a select from the root node, subsequent slashes indicate selecting a child node from current node | +| ```//``` | Select direct and indirect child nodes in the document from the current node - this gives us the ability to "skip levels" | +| ```.``` | Select the current context node | +|```..``` | Select the parent of the context node| +|```@``` | Select attributes of the context node| +|```[@attribute = 'value']``` |Select nodes with a particular attribute value| |`text()`| Select the text content of a node| | ||Pipe chains expressions and brings back results from either expression, think of a set union | -> ## Drill common XPath expressions using the XPath Diner -> -> The [XPath Diner](http://www.topswagcode.com/xpath) is a fun way to practice writing XPath expressions. It shows XML code, with a corresponding display of food, and challenges you to select certain food, and only that food, by writing an appropriate XPath expression. In the pane on the right, it teaches you about expression syntax relevant to the current challenge. -> -{: .challenge} -## Evaluating XPath in a web browser +## Navigating through a webpage with XPath using a browser console We will use the HTML code that describes this very page you are reading as an example. By default, a web browser -interprets the HTML code to determine how to present the various elements of a document, and the code is +interprets the HTML code to determine what markup to apply to the various elements of a document, and the code is invisible. To make the underlying code visible, all browsers have a function to display the raw HTML content of a web page. @@ -251,10 +190,10 @@ We can see from the source code that the title of this page is in a `title` elem `head` element, which is itself inside an `html` element that contains the entire content of the page. Say we wanted to tell a web scraper to look for the title of this page, we would use this information to indicate the -_path_ the scraper would need to follow as it navigates through the HTML content of the page to reach the `title` +_path_ the scraper would need to follow at it navigates through the HTML content of the page to reach the `title` element. XPath allows us to do that. -We can evaluate XPath expressions directly from within all major modern browsers, by enabling the built-in JavaScript console. +We can run XPath queries directly from within all major modern browsers, by enabling the built-in JavaScript console. > ## Display the console in your browser > @@ -270,9 +209,9 @@ Here is how the console looks like in the Firefox browser: ![JavaScript console in Firefox]({{ page.root }}/fig/firefox-console.png) For now, don't worry too much about error messages if you see any in the console when you open it. The console -should display a _prompt_ with a `>` character (`»` in Firefox) inviting you to type commands. +should display a _prompt_ with a `> ` character (`>>` in Firefox) inviting you to type commands. -The syntax to evaluate an XPath expression on the current page within the JavaScript console is `$x("XPATH_QUERY")`. For example: +The syntax to run an XPath query within the JavaScript console is `$x("XPATH_QUERY")`, for example: ~~~ $x("/html/head/title/text()") @@ -301,8 +240,8 @@ the _root_ of the document. With that query, we told the browser to Using this syntax, XPath thus allows us to determine the exact _path_ to a node. -> ## Select the "Matching patterns" title -> Write an XPath query that selects the "Matching patterns" title above and try running it in the console. +> ## Select the "Introduction" title +> Write an XPath query that selects the "Introduction" title above and try running it in the console. > > Tip: if a query returns multiple elements, the syntax `element[1]` can be used. Note that > XPath uses one-based indexing, therefore the first element has index 1, the second has index 2 etc. @@ -317,7 +256,7 @@ Using this syntax, XPath thus allows us to determine the exact _path_ to a node. > > should produce something similar to > > > > ~~~ -> > <- Array [ <h1#matching-patterns> ] +> > <- Array [ <h1#introduction> ] > > ~~~ > > {: .output} > > @@ -329,7 +268,7 @@ ways to reach a specific HTML node using XPath, let's start by looking closer at within a document and what their relationships with each others are. -For example, to select all the `blockquote` elements visible on this page, we can write +For example, to select all the `blockquote` nodes of this page, we can write ~~~ $x("html/body/div/blockquote") @@ -387,38 +326,15 @@ Array [ <blockquote.challenge>, <blockquote.challenge>, <blockquote.challenge>, ~~~ {: .output} -> ## Finding by class name in XPath -> -> In general, an element may have many classes, which are separated by space in -> the attribute. For example the following element has two classes, `author` and -> `author-id3451`. -> -> ~~~ -> <span class="author author-id3451">Jane Bloggs</span> -> ~~~ -> {: .source} -> -> CSS selectors make selecting by class easy: `.author` will select any element -> with the `author` class; `.author-id3451` any element with that class. -> -> XPath is unwieldy for expressing that an attribute should contain a particular -> whitespace-delimited word. The following is *usually* sufficient to match -> any element with an `author` class: -> -> ~~~ -> //*[contains(concat(' ', @class, ' '), ' author ')] -> ~~~ -> {: .source} -{: .callout} -> ## Select the "Matching patterns" title by ID -> In a previous challenge, we were able to select the "Matching patterns" title because we knew it was +> ## Select the "Introduction" title by ID +> In a previous challenge, we were able to select the "Introduction" title because we knew it was > the first `h1` element on the page. But what if we didn't know how many such elements were on the -> page? In other words, is there a different attribute that allows us to uniquely identify that title +> page. In other words, is there a different attribute that allows us to uniquely identify that title > element? > > Using the path expressions introduced above, rewrite your XPath query to select -> the "Matching patterns" title without using the `[1]` index notation. +> the "Introduction" title without using the `[1]` index notation. > > Tips: > @@ -430,33 +346,21 @@ Array [ <blockquote.challenge>, <blockquote.challenge>, <blockquote.challenge>, > > ## Solution > > > > ~~~ -> > $x("/html/body/div/h1[@id='matching-patterns']") +> > $x("/html/body/div/h1[@id='introduction']") > > ~~~ > > {: .source} > > > > should produce something similar to > > > > ~~~ -> > <- Array [ <h1#matching-patterns> ] +> > <- Array [ <h1#introduction> ] > > ~~~ > > {: .output} > > > {: .solution} {: .challenge} -> ## What makes a good XPath expression? -> Essential to web scraping is being able to select the set of elements you want, without selecting any additional elements. -> Many web scrapers are run periodically on web sites with changing data. One challenge is that the structure of that page -> can also change or vary across items being scraped. -> -> A good XPath expression may be characterised by: -> -> * being specific: not capturing things you don't need -> * being robust to change: the expression should ideally still work if some basic things about the page structure change (e.g. an image is inserted; a field, such as an author's name, is absent). If the expression breaks due to change it is _better for it to extract nothing_ than to extract the wrong thing as it is easy to monitor how many XPaths come back empty. -> * being easy to read: if things are going to break or change, readable selectors help to avoid redesigning the selector from scratch. -> -> All of these characteristics suggest preferring IDs and classes (and perhaps other attributes) where possible, and being judicious in choosing between a child or a descendant operator. -{: .callout} + > ## Select this challenge box @@ -688,7 +592,7 @@ XPath Axes fuller syntax of how to use XPath. Provides all of the different ways Oftentimes, the elements we are looking for on a page have no ID attribute or other uniquely identifying features, so the next best thing is to aim for neighboring elements that we can identify more easily and then use node -relationships to get from those easy-to-identify elements to the target elements. +relationships to get from those easy to identify elements to the target elements. For example, the node tree image above has no uniquely identifying feature like an ID attribute. However, it is just below the section header "Navigating through the HTML node tree using XPath". diff --git a/_episodes/03-manual-scraping.md b/_episodes/03-manual-scraping.md new file mode 100755 index 0000000..81e2f62 --- /dev/null +++ b/_episodes/03-manual-scraping.md @@ -0,0 +1,275 @@ +--- +title: "Manually scrape data using browser extensions" +teaching: 45 +exercises: 20 +questions: +- "How can I get started scraping data off the web?" +- "How can I use XPath to more accurately select what data to scrape?" +objectives: +- "Introduce the Chrome Scraper extension." +- "Practice scraping data that is well structured." +- "Use XPath queries to refine what needs to be scraped when data is less structured." +keypoints: +- "Data that is relatively well structured (in a table) is relatively easily to scrape." +- "More often than not, web scraping tools need to be told what to scrape." +- "XPath can be used to define what information to scrape, and how to structure it." +- "More advanced data cleaning operations are best done in a subsequent step." +--- + +# Using the Scraper Chrome extension + +Now we are finally ready to do some web scraping. Let's go back to the list of +[UK House of Commons members](https://www.parliament.uk/mps-lords-and-offices/mps/). + +We are interested in downloading this list to a spreadsheet, with columns for names and +constituencies. Do do so, we will use the Scraper extension in the Chrome browser +(refer to the [Setup](setup/) section for help installing these tools). + +## Scrape similar + +With the extension installed, we can select the first row of the House of Commons members +list, do a right click and choose "Scrape similar" from the contextual menu: + +![Screenshot of the Scraper contextual menu]({{ page.root }}/fig/scraper-contextmenu.png) + +Alternatively, the "Scrape similar" option can also be accessed from the Scraper extension +icon: + +![Screenshot of the Scraper menu]({{ page.root }}/fig/scraper-menu.png) + +Either operation will bring up the Scraper window: + +![Screenshot of the Scraper main window]({{ page.root }}/fig/scraper-ukparl-01.png) + +We recognize that Scraper has generated XPath queries that corresponds to the data we had +selected upon calling it. The Selector (highlighted in red in the above screenshot) + has been set to `//tbody/tr[td]` which selects +all the rows of the table, delimiting the data we want to extract. + +In fact, we can try out that query using the technique that we learned in the previous +section by typing the following in the browser console: + +~~~ +$x("//tbody/tr[td]") +~~~ +{: .source} + +returns something like + +~~~ +<- Array [672] +~~~ +{: .output} + +which we can explore in the console to make sure this is the right data. + +Scraper also recognized that there were two columns in that table, and has accordingly +created two such columns (highlighted in blue in the screenshot), +each with its own XPath selector, `*[1]` and `*[2]`. + +To understand what this means, we have to remember that XPath queries are relative to the +current context node. The context node has been set by the Selector query above, so +those queries are relative to the array of `tr` elements that has been selected. + +We can replicate their effect by trying out + +~~~ +$x("//tbody/tr[td]/*[1]") +~~~ +{: .source} + +in the console. This should select only the first column of the table. The same goes for the +second column. + +But in this case, we don't need to fiddle with the XPath queries too much, as Scraper was able to deduce +them for us, and we can use the export functions to either create a Google Spreadsheet with the +results, or copy them into the clipboard in Tab Separated Values (TSV) format for pasting into +a text document, a spreadsheet or Open Refine. + +There is one bit of data cleanup we might want to do, though. If we paste the data copied from Scraper +into a text document, we see something like this: + +~~~ +Name Constituency +A back to top + Abbott, Ms Diane (Labour) Hackney North and Stoke Newington + Abrahams, Debbie (Labour) Oldham East and Saddleworth +~~~ +{: .output} + +This is because there are a lot of unnecessary white spaces in the HTML that's behind that table, which +are being captured by Scraper. We can however tweak the XPath column selectors to take advantage of the +`normalize-space` XPath function: + +~~~ +normalize-space(*[1]) +normalize-space(*[2]) +~~~ + +![Screenshot of the Scraper window showing the Column selectors]({{ page.root }}/fig/scraper-ukparl-02.png) + +We now need to tell Scraper to scrape the data again by using our new selectors, this is done by clicking +on the "Scrape" button. The preview will not noticeably change, but if we now copy again the results +and paste them in our text editor, we should see + +~~~ +Name Constituency +A back to top +Abbott, Ms Diane (Labour) Hackney North and Stoke Newington +Abrahams, Debbie (Labour) Oldham East and Saddleworth +Adams, Nigel (Conservative) Selby and Ainsty +~~~ +{: .output} + +which is a bit cleaner. + +> ## Scrape the list of Ontario MPPs +> Use Scraper to export the list of [current members of the Ontario Legislative Assembly](http://www.ontla.on.ca/web/members/members_current.do?locale=en) +> and try exporting the results in your favourite spreadsheet or data analysis +> software. +> +> Once you have done that, try adding a third column containing the URLs that are underneath +> the names of the MPPs and that are leading to the detail page for each parliamentarian. +> +> Tips: +> +> * To add another column in Scraper, use the little green "+" icon in the columns list. +> * Look at the source code and try out XPath queries in the console until you find what +> you are looking for. +> * The syntax to select the value of an attribute of the type `<element attribute="value">` +> is `element/@attribute`. +> * The `concat()` XPath function can be use to concatenate things. +> +> > ## Solution +> > +> > Add a third column with the XPath query +> > +> > ~~~ +> > *[1]/a/@href +> > ~~~ +> > {: .source} +> > +> > ![Screenshot of the Scraper window on the Ontario MPP page]({{ page.root }}/fig/scraper-ontparl-01.png) +> > +> > This extracts the URLs, but as luck would have it, those URLs are relative to the list +> > page (i.e. they are missing `http://www.ontla.on.ca/web/members/`). We can use the +> > `concat()` XPath function to construct the full URLs: +> > +> > ~~~ +> > concat('http://www.ontla.on.ca/web/members/',*[1]/a/@href) +> > ~~~ +> > {: .source} +> > +> > ![Screenshot of the Scraper window on the Ontario MPP page]({{ page.root }}/fig/scraper-ontparl-02.png) +> > +> {: .solution} +{: .challenge} + + + +## Custom XPath queries + +Sometimes, however, we do have to do a bit of work to get Scraper to select the data elements +that we are interested in. + +Going back to the example of the Canadian Parliament we saw in the introduction, +there is a page on the same website that [lists the mailing addresses](http://www.parl.gc.ca/Parliamentarians/en/members/addresses) of all +parliamentarians. We are interested in scraping those addresses. + +If we select the addresses for the first MP and try the "Scrape similar" function... + +![Screenshot of the Scraper context menu being used on an address block]({{ page.root }}/fig/scraper-canparl-01.png) + +Scraper produces this: + +![Screenshot of the Scraper window trying to scrape addresses]({{ page.root }}/fig/scraper-canparl-02.png) + +which does a nice job separating the address elements, but what if instead we want a table of +the addresses of all MPs? Selecting multiple addresses instead does not help. Remember what we said +about computers not being smart about structuring information? This is a good example. We humans +know what the different blocks of texts on the screen mean, but the computer will need some help from +us to make sense of it. + +We need to tell Scraper what exactly to scrape, using XPath. + +If we look at the HTML source code of that page, we see that individual MPs are all within `ul` +elements: + +~~~ +(...) +<ul> + <li><h3>Aboultaif, Ziad</h3></li> + <li> + <span class="addresstype">Hill Office</span> + <span>Telephone:</span> + <span>613-992-0946</span> + <span>Fax:</span> + <span>613-992-0973</span> + </li> + <li> + <ul> + <li><span class="addresstype">Constituency Office(s)</span></li> + <li> + <span>8119 - 160 Avenue (Main Office)</span> + <span>Suite 204A</span> + <span>Edmonton, Alberta</span> + <span>T5Z 0G3</span> + <span>Telephone:</span> <span>780-822-1540</span> + <span>Fax:</span> <span>780-822-1544</span> + <span class="spacer"></span> + </li> + </ul> + </li> +</ul> +(...) +~~~ +{: .output} + +So let's try changing the Selector XPath in Scraper to + +~~~ +//body/div[1]/div/ul +~~~ +{: .source} + +and hit "Scrape". We get something that is closer to what we want, with one line per MP, but +the addresses are still all in one block of unstructured text: + +![Screenshot of the Scraper window trying to scrape addresses]({{ page.root }}/fig/scraper-canparl-03.png) + +Looking closer at the HTML source, we see that name and addresses are separated by `li` elements +within those `ul` elements. So let's add a few columns based on those elements: + +~~~ +./li[1] -> Name +./li[2] -> Hill Office +./li[3] -> Constituency +~~~ +{: .source} + +This produces the following result: + +![Screenshot of the Scraper window scraping addresses]({{ page.root }}/fig/scraper-canparl-04.png) + +The addresses are still one big block of text each, but at least we now have a table for all MPs +and the addresses are separated. + +> ## Scrape the Canadian MPs' phone numbers +> Keep working on the example above to add a column for the Hill Office phone number +> and fax number for each MP. +> +> +> > ## Solution +> > +> > Add columns with the XPath query +> > +> > ~~~ +> > ./li[2]/span[3] -> Hill Office Phone +> > ./li[2]/span[5] -> Hill Office Fax +> > ~~~ +> > {: .source} +> > +> > ![Screenshot of the Scraper window on scraping MP phone numbers]({{ page.root }}/fig/scraper-canparl-05.png) +> > +> {: .solution} +{: .challenge} diff --git a/_episodes/03-visual-scraping.md b/_episodes/03-visual-scraping.md deleted file mode 100644 index 43dbe84..0000000 --- a/_episodes/03-visual-scraping.md +++ /dev/null @@ -1,261 +0,0 @@ ---- -title: "Visual scraping using browser extensions" -teaching: 45 -exercises: 25 -questions: -- "How can I get started scraping data off the web?" -- "How can I use CSS selectors to precisely select what data to scrape?" -objectives: -- "Introduce the Chrome Web Scraper extension." -- "Practice scraping data that is largely well structured, merging data from many pages." -- "Use CSS selectors to refine what needs to be scraped when data is less structured." -keypoints: -- "Data that is relatively well structured (in a table) is relatively easily to scrape." -- "More often than not, web scraping tools need to be told what to scrape." -- "CSS selectors can be used to define what information to scrape, and how to structure it." -- "CSS selectors in scrapers need to be designed careful, as the selector chosen for one page may not work perfectly on another." -- "More advanced data cleaning operations are best done in a subsequent step." ---- - -# An introduction to visual scrapers - -Visual scrapers are tools in which the user can visually select the elements to extract, and the logical order to follow in performing a sequence of extractions. They require little or no code, and assist in designing XPath or CSS selectors. - -Visual scraping tools vary in how flexible they are (in comparison to the full expressiveness of coding your own), how easy to use, to what extent they help you identify and debug scraping problems, how easy it is to keep and transfer your scraper to another service, and how costly the service is. -Many visual scrapers require you to pay for their services beyond a small number of trial extractions, may only store your data for a limited time, and may not provide a way for you to take your scraper off their site for reuse or extension. -Some do not allow you to write your own XPath / CSS / regular expression selectors; some only support CSS or XPath but not the other. - -> ## Why we chose the Web Scraper extension -> In designing this lesson, we have chosen to emphasise free solutions that give you ultimate control of the scraper and its data. -> As of June 2017, we have only found a few visual scraping tools that are [Free Open-Source Software](https://en.wikipedia.org/wiki/Free_and_open-source_software), including [webscraper.io's Web Scraper Chrome extension](http://webscraper.io/), [David Heaton's Scraper Chrome extension](https://github.com/mnmldave/scraper) and [Portia](https://scrapinghub.com/portia/). -> While there are numerous advantages to Portia, we found it relatively difficult to install and ran into bugs (though it calls itself a Beta, so bugs are to be expected). -> Scraper is limited to extracting data from a single page, and also had some issues when we tested it. -> In comparison to refined commercial tools, Web Scraper's user experience leaves much to be desired, but it is a flexible tool (although it does not support XPath) and a useful introduction to scraping without coding. -{: .callout} - -See [Setup]({{page.root}}/Setup) for instructions on installing the Web Scraper browser extension. - -# Using the Web Scraper Chrome extension - -We are finally ready to do some web scraping. Let's go to the index of -[UNSC resolutions](http://www.un.org/en/sc/documents/resolutions/) in our Chrome browser. - -To use the Web Scraper, we need to open the Developer Tools as in the previous episode (right click on the page and choose _Inspect Element_ is often the simplest way in). In the Developer Tools, you should find a tab entitled _Web Scraper_. Activate the tab, click _Create new sitemap_ below it and then _Create sitemap_, as numbered in the following: - -![Creating a new sitemap]({{ page.root }}/fig/web-scraper-create.png) - -(If the Developer Tools were not docked at the bottom of your web browser window (usually they are), you will need to [dock them there](https://stackoverflow.com/questions/10023640/how-to-reposition-chrome-developer-tools).) - -_Sitemap_ is essentially the Web Scraper extension's name for a scraper. It is a sequence of rules for how to extract data by proceeding from one extraction to the next. We'll name the sitemap "unsc-resolutions", set the start page as `http://www.un.org/en/sc/documents/resolutions/`, and click _Create Sitemap_. - -Before we start constructing the sitemap, let's try to understand the structure of a complete sitemap. - -## The selector graph: here's one we made earlier - -A Web Scraper sitemap consists of a collection of selectors each of which may identify: - -* specific content to extract; -* elements of the page containing content to extract (e.g. an entry in a catalogue, each of which contains multiple specific pieces of content, like model, brand, price, etc.); or -* a link to follow and continue scraping from. - -Each selector (except a special one called `_root`) has a parent selector defining the context in which each selector is to be applied. For example, the following shows a visual representation ("Selector graph") of the final scraper we will build for the UNSC resolutions: - -![Selector graph for UNSC resolutions]({{ page.root }}/fig/web-scraper-unsc-graph.png) - -Here `_root` represents the starting URL, the home page of UNSC resolutions. From it, the scraper gets a link to each `year` page. For each year, it extracts a set of `resolution` elements. For each `resolution` element, it extracts a single `symbol`, a single `date`, a single `title`, and a single `url`. - -Since the years are linked from the start page, `_root` is the parent of the `year` selector. Since resolutions can only be extracted once on a year page, `year` is the parent selector of `resolution`. Similarly, since a symbol is extracted for each resolution, `resolution` is the parent selector of `symbol`. Etc. - -## Navigating from root to year pages - -At this point, we have the Web Scraper tool open at the `_root` with an empty list of child selectors. - -![An empty list of selectors at root]({{ page.root }}/fig/web-scraper-empty-selector-list.png) - -Click _Add new selector_. We will add the selector that takes us from the index to each year page. Let's give it the id `year`. Its type is _Link_. We want to get multiple year links from the root, so we will check the Multiple box below. - -Under _Selector_, there are tools for building a CSS selector. Rightmost (highlighted blue below) is a text box where we can enter a CSS selector. The _Select_ button gives us a tool for visually selecting elements on the page to construct a CSS selector. _Element Preview_ highlights on the page those elements that would be selected by the specified selector. _Data Preview_ pops up a sample of the data that would be extracted by the specified selector. - -![Adding a year selector]({{ page.root }}/fig/web-scraper-year-selector.png) - -Let's start by entering the selector `a`, which will match all `<a>` (hyperlink) elements in the page. Click _Element Preview_ and all links in the page you are viewing will blush. (You must be talking about them!) Click _Data Preview_ and we'll see that from the set of links we can scrape a table consisting of the text and the link URL (plus a couple of administrative details). - -We only want to capture year links, not all links, in the page. We could construct the CSS selector by inspecting the page's source or element tree. Instead we will use Web Scraper's _Select_ feature. - -Click _Select_. A small selection tool will appear above the Developer Tools, hovering over the UNSC page. Hover your mouse over one of the year links and it should be highlighted in green: - -![Using the Select popup feature]({{ page.root }}/fig/web-scraper-select-popup.png) - -Click one of the year links. A very specific CSS selector such as `tr:nth-of-type(3) td:nth-of-type(1) a` will be filled in on the left of the selection tool, and the year you clicked will be reddened to indicate that it is included in the proposed selector. Click one of the other (unselected) year links and the CSS selector should be adjusted to include it. Keep clicking years until all of them are selected. (If you make a mistake, or if -- unfortunately -- Web Scraper refuses to let you select all the links you desire, click the _Select_ button in the main Web Scraper tool to start again.) The final selector should be `td a`, which will select every link (`<a>`) element anywhere inside a table cell (`<td>`) element anywhere in the page. Click _Done Selecting_ and the identified selector will appear in the text box where we entered `a` before. - -We do not require the scraper to delay before selecting each year, nor do we need to change the parent selector (`_root` is correct). So click _Save Selector_. This returns us to the list of selectors that are children of `_root`. Now we have one: the `year` selector. - -### Running the scraper - -What happens if we run the scraper as it is now? To do so, click _Sitemap (unsc-resolutions)_ to get a drop-down menu, and click Scrape as shown: - -![Using the Select popup feature]({{ page.root }}/fig/web-scraper-dropdown-scrape.png) - -The scrape pane gives us some options about how slowly Web Scraper should perform its scraping to avoid overloading the web server with requests and to give the web browser time to load pages. We are fine with the defaults, so click _Start scraping_. A window will pop up, where the scraper is doing its browsing. The list of year links will be scraped, and the window will close, as the scraping is complete! We can see a table of `year` and `year-href` values to show us that our very simple scraper has worked! The _Export data as CSV_ entry on the drop-down menu will even bring the scraped data into Excel. - -Click _Sitemap (unsc-resolutions)_ to get the drop-down menu again, and _Selectors_ will return you to the root selectors. Note that you can click _Data preview_ for a quick and dirty alternative to actually running the scrape. - -## A selector for resolutions - -Clicking the `year` ID will take you to _its_ child selectors, i.e. the things to scrape on every year page; there are none. Clicking `year` will _not_ take you to an example year page. But since its child selectors only apply in the context of each year page, you will have to click a year link yourself -- say, [2016](http://www.un.org/en/sc/documents/resolutions/2016.shtml) -- to design `year`'s child selectors. - -We will now create a selector which captures _each element containing data for a single resolution_, i.e. each selected item should be a row of the table. - -* id: `resolution` -* type: Element -* multiple: checked -* parent selector: `year` -* selector: ??? - -Note that here we want to select an *Element* type, as we want to be able to further scrape within each of the resolution elements; we don't just want its text, for instance. - -The selector for resolutions is, in this case, a bit tricky, for two reasons: - -1. As you can see by inspecting the page source, each resolution is presented in a table row `<tr>` element. However: the table title is also a row, but doesn't contain resolution data! So a simple CSS selector like `tr` which captures all table rows will not suffice. We cannot use CSS2 Selectors to say that we'd only like rows containing more than one `<td>` cell (though we could do this kind of thing with XPath). We can, however, use CSS2 selectors to get all but the first using an advanced `:nth-child` or `:nth-of-type` selector. -2. We want each selected element to contain *all* the data for a single resolution, not just its title, for instance. Using the visual _Select_ tool, it is hard to select a row in entirety, as clicking anywhere in a table will select a cell `<td>` element or something within it, rather than the row as a whole. To facilitate selecting the whole row, the _Select_ tool has a feature where pressing **P** on your keyboard will change the proposed selector so that it selects the _parents_ of the currently selected elements. So if you select a cell from the table and hit **P** it should select the row. - -> ## Challenge: Construct a selector to get all resolution rows -> Using either the _Select_ tool (and its **P** feature), or by manually composing an advanced (formula-based) `:nth-of-type` CSS Selector, capture all and only resolution rows from the page. -> -> > ## Solution -> > One solution CSS selector is `tr:nth-of-type(n+2)`. To get this with the visual _Select_ tool: -> > 1. Click _Select_ to launch the tool -> > 2. Click the top cell of the table with a resolution title in it. A selector such as `tr:nth-of-type(2) td:nth-of-type(3)` should appear. -> > 3. Press **P** on your keyboard. The selector should now become something like `tr:nth-of-type(2)`. -> > 4. Click on another row of data. The selector should now be `tr:nth-of-type(n+2)`. Confirm that all the rows we want are included. Click _Done Selecting_. -> {: .solution} -{: .challenge} - -Save selector! - -## The data for each resolution - -We finally need to add child selectors of the `resolution` selector. Click the row for the `resolution` selector to see its children. There are currently none. Let's make some for `symbol`, `url`, `date` and `title`. - -Click _Add new selector_, and enter: - -* id: `symbol` -* type: Text -* selector: `td:nth-of-type(1)` -* multiple: not checked -* parent: `resolution` - -Note that we do not check _multiple_ because, although there are multiple on the page, we only want one per `resolution`, being the context (parent) of this selector. Note, similarly, that using the _Select_ tool only allows us to select from within the first matching resolution element. Save selector! - -Add another: - -* id: `symbol` -* type: Element attribute (although you could instead use Link) -* selector: `a` -* multiple: not checked -* attribute name: `href` -* parent: `resolution` - -Using the `Element attribute` type allows us to get the value of the `href` attribute on each `<a>` element in the row. The `href` attribute is where the link target is stored. For example, one HTML fragment looks like: - -~~~ -<td class="class"><a href="http://www.un.org/en/ga/search/view_doc.asp?symbol=S/RES/2335(2016)">S/RES/2335 (2016)</a></td> -~~~ -{: .output} - -We should at this point use the _Data Preview_ feature to see what will be extracted. For instance, click `year`: - -![Clicking `year` for data preview]({{page.root}}/fig/web-scraper-click-year-for-preview.png) - -Then click Data Preview on the `resolution` row to see the following: - -![Resolution data preview]({{page.root}}/fig/web-scraper-data-preview.png) - -(Note that we intentionally did not click `_root` for data preview, because the data preview feature can only show data extracted from the current page. The current page is a resolution page, while `_root`'s child selectors only work on the index page.) - -> ## Challenge: add new selectors for `date` and `title` -> Add new selectors under `resolution` for a resolution's title and date fields. -> > ## Solution -> > The `date` selector could be: -> > * id: `date` -> > * type: Text -> > * selector: `td:nth-of-type(2)` -> > * multiple: not checked -> > * parent: `resolution` -> > -> > The `title` selector could be: -> > * id: `date` -> > * type: Text -> > * selector: `td:nth-of-type(3)` -> > * multiple: not checked -> > * parent: `resolution` -> {: .solution} -{: .challenge} - -> ## Improving open-source tools -> We feel that some of this interface is quite unintuitive. If you have specific constructive critique for how the Web Scraper tool can be improved, you should: -> * Look at the [list of issues](https://github.com/martinsbalodis/web-scraper-chrome-extension/issues) for the project and search through it to see if a similar suggestion has already been made. Perhaps use a GitHub account to indicate your support for that suggestion. -> * [Create a new issue](https://github.com/martinsbalodis/web-scraper-chrome-extension/issues/new) to suggest a change or highlight a problem. -> * Consider assisting in the development of the extension, if you have sufficient experience with the technologies used (JavaScript, HTML, CSS, etc.). -{: .callout} - -## More data previews and some fixes - -Inspecting the Data Preview on `resolution` again, things look okay. - -![Complete resolution data preview for 2016]({{page.root}}/fig/web-scraper-data-preview2.png) - -Or at least they do for 2016. - -> ## Challenge: using Data Preview to identify this scraper's failures -> Now run the Data Preview on the page for [1999](http://www.un.org/en/sc/documents/resolutions/1999.shtml). -> There the date column does not exist. What does the scraper get wrong? -> -> > ## Solution -> > We note that the date column doesn't exist, the `resolution` Data Preview shows us some issues. -> > ![Broken resolution data preview for 1999]({{page.root}}/fig/web-scraper-data-preview-1999bad.png) -> > -> > * `date` is filled with titles -> > * `title` is filled with `null` -> > * `url` doesn't have `http://...` at the front -> {: .solution} -{: .challenge} - -A visual scraper may help you build the CSS selector for a set of elements on a page, but that CSS selector might not be the best match for *all* pages you wish to scrape. (But most web sites aren't this quirky, either!) - -We need to get a bit creative and use advanced techniques to handle pages with and without a date column, and the variation in URL format. Visual scraping may handle variation in the page structure poorly, which motivates having more control over your scraper by coding it up as we will in the next episode. - -Possible solutions using the Web Scraper extension: - -* We can more-or-less fix the `url` issue by telling Web Scraper to extract `symbol` as as Link (not a Text) with the `a` selector. This will extract the full (resolved) URL of the link as well as the link text, in two separate columns of the extracted data. We can then delete the `url` selector. -* For the `title` we can change the selector from `td:nth-of-type(3)` to `td:nth-last-of-type(1)`, as it is always the *last* column but not always the third. -* And we can fix (hackily!) the `date` issue by requiring that the date text have a certain form. We can use regular expressions: enter `^[0-9].*[0-9]$` in the _Regex_ field. This matches only text which begins with a digit and ends with a digit. Hopefully (but we should check after the fact) this will not match any titles. - -## Run it! - -Choose _Scrape_ from the drop-down menu and _Start Scraping_. - -A window pops up where Web Scraper is doing its work: starting at the index then proceeding to each page of resolutions in turn. -It will take around 5 minutes to run. -It should be possible to _Browse_ (under _Scrape_ in the drop-down menu) the data being collected during scraping. - -You can also save a machine readable copy of your scraper details by selecting _Export Sitemap_ and copying the code there to a file. - -When it is finished, _Export data as CSV_ and view the data in spreadsheet software such as Excel or Google Sheets. - - -> ## Extension challenge: count how many resolutions there are per year -> Use spreadsheet software to count the number of resolutions per year. Are any numbers surprising? -> -> Hint: consider using a Pivot Table, and then a bar chart of the counts. -> > ## Solution -> > Here is a bar chart of resolutions by year constructed from a pivot table in Excel: -> > ![Bar chart of resolutions by year]({{page.root}}/fig/web-scraper-unsc-bar-chart.png) -> > -> > Apart from the general increase in the rate of resolutions produced in the 1990s, 1960 stands out as an outlier. It turns out that our data has duplicate records in it. We will discuss this in the next episode. -> {: .solution} -{: .challenge} - -# References - -* [Web Scraper web site and tutorials](http://webscraper.io/) diff --git a/_episodes/04-lxml.md b/_episodes/04-lxml.md deleted file mode 100644 index 9d787f5..0000000 --- a/_episodes/04-lxml.md +++ /dev/null @@ -1,742 +0,0 @@ ---- -title: "Web scraping using Python: requests and lxml" -teaching: 40 -exercises: 30 -questions: -- "How can scraping a web site be automated?" -- "How can I download web pages' HTML in Python?" -- "How can I evaluate XPath or CSS selectors in Python?" -- "How can I format scraped data as a spreadsheet?" -- "How do I build a scraper that will keep working even if the page structure changes?" -objectives: -- "Using `requests.get` and resolving relative URLs with `urljoin`" -- "Traversing HTML and extracting data from it with `lxml`" -- "Creating a two-step scraper to first extract URLs, visit them, and scrape their contents" -- "Apprehending some of the things that can break when scraping" -- "Storing the extracted data" -keypoints: -- "`requests` is a Python library that helps downloading web pages, primarily with `requests.get`." -- "`requests.compat.urljoin(response.url, href)` may be used to resolve a relative URL `href`." -- "`lxml` is a Python library that parses HTML/XML and evaluates XPath/CSS selectors." -- "`lxml.html.fromstring(page_source)` will produce an element tree from some HTML code." -- "An element tree's `cssseelct` and `xpath` methods extract elements of interest." -- "A scraper can be divided into: identifying the set of URLs to scrape; extracting some elements from a page; and transforming them into a useful output format." -- "It is important but challenging to be resilient to variation in page structure: one should automatically validate and manually inspect their extractions." -- "A framework like [Scrapy](http://scrapy.org) may help to build robust scrapers, but may be harder to learn. See [the Scrapy tutorial in Extras]({{page.root}}/scrapy)." ---- - -# Recap -Here is what we have learned so far: - -* We can use XPath or CSS selectors to select what elements on a page to scrape. -* We can look at the HTML source code of a page to find how target elements are structured and - how to select them. -* We can use the browser console to try out XPath or CSS selectors on a live site. -* We can use visual scrapers to handle some basic scraping tasks. These help determine an appropriate selector, and may be able to navigate through a web site collecting data. - -This is quite a toolset already, and it's probably sufficient for a number of use cases, but there are -limitations in using the tools we have seen so far. -For example, some data may be structured in ways that are too out of the ordinary for visual scrapers, perhaps requiring items to be processed only in certain conditions. -There may also be too much data, or too many pages to visit, to simply run the scraper in a web browser, as some visual scrapers operate. -Writing a scraper in code may make it easier to maintain and extend, or to incorporate quality assurance and monitoring mechanisms. - -# Introducing Requests and lxml - -We make use of two tools that are not specifically developed for scraping, but are very useful for that purpose (among others). -Both of these require a Python installation (Python 2.7, or Python 3.4 and higher; although our example code will focus on Python 3), -and each library (requests and lxml and cssselect) needs to be installed as described in [Setup]({{page.root}}/Setup). - -[Requests](http://docs.python-requests.org/en/latest/) focuses on the task of interacting with web sites. -It can download a web page's HTML given its URL. -It can submit data as if filled out in a form on a web page. -It can manage cookies, keeping track of a logged-in session. -And it helps handling cases where the web site is down or takes a long time to respond. - -[lxml](http://lxml.de) is a tool for working with HTML and XML documents, represented as an *element tree*. -It evaluates XPath and CSS selectors to find matching elements. -It facilitates navigating from one element to another. -It facilitates extracting the text, attribute values or HTML for a particular element. -It knows how to handle badly-formed HTML (such as an opening tag that is never closed, or a closing tag that is never opened), although it may not handle it identically to a particular web browser. -It is also able to construct new well-formed HTML/XML documents, element by element. - -To use CSS selectors, the [cssselect](https://pypi.python.org/pypi/cssselect) package must also be installed. - -If all are correctly installed, it should be possible to then write the following Python code without an error occurring: - -~~~ ->>> import requests ->>> import lxml ->>> import cssselect -~~~ -{: .source} - -We will be working in Python. Open a text editor or IDE (such as Spyder) to edit a new file, saved as `unsc-scraper.py`. -Check that you can run the file with Python, e.g. by running the following in a terminal: - -~~~ -$ python unsc-scraper.py -~~~ -{: .source} - -If `unsc-scraper.py` is empty, this should run but not output anything to the terminal. - -## Downloading a page with requests - -Let's start by downloading the page of UNSC resolutions for 2016. Enter the following in your file and save: - -~~~ -import requests - -response = requests.get('http://www.un.org/en/sc/documents/resolutions/2016.shtml') -print(response.text) -~~~ -{: .python} - -You should see the same as what you would when using a web browser's _View Source_ feature (albeit less colourful): - -``` -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> -<head> -<meta http-equiv="X-UA-Compatible" content="IE=8" /> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Resolutions adopted by the United Nations Security Council since 1946 -... -``` -{: .output} - -What's it doing? - -* `import requests` has made the requests library available to your Python code. -* `requests.get(URL)` tries to request the URL from the web server and returns a `Response` object which includes various details about the request and its response. -* `response.text` reads all the content sent back by the web server (and raises an error if the request was unsuccessful), in this case HTML source code. - -We now have the page content, but as a string of textual characters, not as a tree of elements. - -## Traversing elements in a page with lxml - -The following illustrates loads the response HTML into a tree of elements, and illustrates the `xpath` and `cssselect` methods provided on an ElementTree (and each Element thereof), as well as other tree traversal. -Running the following code: - -~~~ -import requests -import lxml.html - -response = requests.get('http://www.un.org/en/sc/documents/resolutions/2016.shtml') -tree = lxml.html.fromstring(response.text) -title_elem = tree.xpath('//title')[0] -title_elem = tree.cssselect('title')[0] # equivalent to previous XPath -print("title tag:", title_elem.tag) -print("title text:", title_elem.text_content()) -print("title html:", lxml.html.tostring(title_elem)) -print("title tag:", title_elem.tag) -print("title's parent's tag:", title_elem.getparent().tag) -~~~ -{: .python} - -produces this output: - -~~~ -title tag: title -title text: Resolutions adopted by the United Nations Security Council in 2016 -title html: b'Resolutions adopted by the United Nations Security Council in 2016 \n' -title tag: title -title's parent's tag: head -~~~ -{: .output} - -This code begins by building a tree of Elements from the HTML using `lxml.html.fromstring(some_html)`. It then illustrates some operations on the elements. -With some element, `elem`, or the tree: - -* `elem.xpath(some_path)` and `elem.cssselect(some_selector)` find a list of nodes relative to `elem` matching the given XPath or CSS selector expression, respectively. -* `elem.getparent()` gets the parent element of `elem`. Similarly, `elem.getprevious()` and `elem.getnext()` may return a single element, or None. -* `elem.getchildren()` gets a list of the children of `elem`, while `elem.getiterator()` allows for iterating over all the descendants of `elem`. (Not illustrated above.) -* `elem.tag` is `elem`'s tag name. -* `elem.text_content()` gets the text of an element and all of its children -* `elem.attrib` is a dict of the attributes of `elem`. -* `lxml.html.tostring(elem)` translates the element back into HTML/XML. - -In the above example, we extract the first (and only) `` element from the page, show its text, etc., and do the same for its parent, the `<head>` node. -When we print the text of that parent node, we see that it consists of two blank lines. Why? - -Apart from basic features of Python, these are all the tools we should need. - -# UNSC scraper overview - -Now that we have some idea of what requests and lxml do, let's use them to scrape UNSC data. -We will modularise our scraper design as follows: - -1. A `get_year_urls` function will return a list of year URLs to scrape resolutions from. -2. A function `get_resolutions_for_year` will return an object like `{'date': '1962', 'symbol': 'S/RES/174 (1962)', 'title': 'Admission of new Members to the UN: Jamaica', 'url': 'http://www.un.org/en/ga/search/view_doc.asp?symbol=S/RES/174(1962)'}` for each resolution at the given page URL. -3. The scraper script will run `get_year_urls`, and then `get_resolutions_for_year` for each year and write the resolutions in CSV to the file `unsc-resolutions.csv`. - -# Spidering pages of UNSC resolutions - -We'll start by compiling a list of URLs to scrape. We will write a Python function called `get_year_urls`. Its job is to get the set of URLs listing resolutions, which we will later scrape. - -For a start, the following function will extract and return a list of the URLs linked to from the starting page: - -~~~ -def get_year_urls(): - start_url = 'http://www.un.org/en/sc/documents/resolutions/' - response = requests.get(start_url) - tree = lxml.html.fromstring(response.text) - links = tree.cssselect('a') # or tree.xpath('//a') - - out = [] - for link in links: - # we use this if just in case some <a> tags lack an href attribute - if 'href' in link.attrib: - out.append(link.attrib['href']) - return out -~~~ -{: .python} - -Calling this function and printing its output should produce something like the following: - -~~~ -print(get_year_urls()) -~~~ -{: .python} - -~~~ -["#mainnav", "#content", "http://www.un.org/en/index.html", "/ar/sc/documents/resolutions/", …, "http://undocs.org/rss/scdocs.xml", "2010.shtml", "2011.shtml", …] -~~~ -{: .output} - -We are faced with two issues: - -1. We only want to get the year-by-year resolutions listings, and should ignore the other links. -2. Only the URLs starting with `http://` can directly be passed into `requests.get(url)`. The others are termed *relative URLs* and need to be modified to become *absolute*. - -> ## Dealing with relative URLs -> -> Most of the URLs found in `href` attributes are _relative_ to the page we found them in. We could -> prefix all those URLs with `http://www.un.org/en/sc/documents/resolutions/` -> to make them absolute, but that doesn't handle all the cases. -> Since this is a common need, we can use an -> existing function, `requests.compat.urljoin(base_url, relative_url)` which will translate: -> -> | From relative URL | To absolute URL | -> |----------------------------------|-----------------------------------------------------------| -> | `#mainnav` | `http://www.un.org/en/sc/documents/resolutions/#mainnav` | -> | `2010.shtml` | `http://www.un.org/en/sc/documents/resolutions/2010.shtml`| -> | `/ar/sc/documents/resolutions/` | `http://www.un.org/ar/sc/documents/resolutions/` | -> | `http://www.un.org/en/index.html`| `http://www.un.org/en/index.html` (unchanged) | -> -> Here, the `base_url` is something like `"http://www.un.org/en/sc/documents/resolutions/2010.shtml"` and the relative URL is something like `"#mainnav"`. -> However, beware: the base URL is not always identical to the URL you pass into `requests.get(url)` for two reasons: -> -> * When you got the URL it may have redirected you to a different page. URLs are therefore relative to the response URL, stored in `response.url`, rather than the request URL. For example, `requests.get("http://www.un.org/ar/sc/documents/resolutions").url` returns `"http://www.un.org/ar/sc/documents/resolutions/"`. Note that this subtly, but importantly, adds a `"/"` at the end. -> * The HTML on a page can indicate that the base for its relative URLs is something else. (See [W3Schools on `<base>`](https://www.w3schools.com/tags/tag_base.asp).) That is, if `tree.xpath('//head/base@href')` returns something, you should use its first value as the base URL. This does not apply in our case because there is no `<base>` tag in the page we are scraping. -> -> (A Python scraping framework, [Scrapy](https://scrapy.org/), recently introduced a way to avoid some of these pitfalls, using `response.follow`. This is not applicable when using `requests` and `lxml` directly. -{: .callout} - -> ## Challenge: Get absolute URLs for year pages -> -> Complete the `get_year_urls` by function fixing the two issues listed above: it should resolve the relative URLs and only get URLs corresponding to yearly resolution listings. -> -> > ## Solution -> > We use a more specific CSS selector, along with `urljoin`: -> > -> > ~~~ -> > def get_year_urls(): -> > """Return a list of (year_url, year) pairs -> > """ -> > start_url = 'http://www.un.org/en/sc/documents/resolutions/' -> > response = requests.get(start_url) -> > tree = lxml.html.fromstring(response.text) -> > links = tree.cssselect('#content > table a') -> > -> > out = [] -> > for link in links: -> > year_url = urljoin(response.url, link.attrib['href']) -> > out.append(year_url) -> > -> > return out -> > ~~~ -> > {: .python} -> > -> > The following describe alternative solutions: -> > -> > 1. Use the same CSS selector as above (`a`), but filter the URLs for those that look like they end in a number followed by `.shtml`. -> > 2. Generate all the URLs without downloading the start page, by simply counting from 1946 to the current year, which can be found with `import datetime; datetime.datetime.now().year`. -> > 3. Use a different CSS selector for the same content (e.g. `table a` or `td > a`). -> {: .solution} -{: .challenge} - -In the final version of `get_year_urls`, we make a couple of modifications, to ensure we're getting what we want, and to return the year number along with the URL (by getting it from `link.text_content()`): - -~~~ -def get_year_urls(): - """Return a list of (year_url, year) pairs - """ - start_url = 'http://www.un.org/en/sc/documents/resolutions/' - response = requests.get(start_url) - tree = lxml.html.fromstring(response.text) - tables = tree.cssselect('#content > table') - # Check you captured something and not more than you expected - if len(tables) != 1: - print('Expected exactly 1 table, got {}'.format(len(tables))) - return [] - - table = tables[0] - links = table.cssselect('a') - - out = [] - for link in links: - year_url = urljoin(base_url, link.attrib['href']) - year = link.text_content() - # TODO: validate that year is actually an appropriate number - out.append((year_url, year)) - - # Check we got something - if not out: - print('Expected some year URLs, got none') - return out -~~~ -{: .python} - -In this implementation, we first extract the `<table>` element, roughly make sure it's what we want, and then apply a CSS selector to get the content within it. - -It's a good idea to check you're getting the kind of data you expect, because: - -* If we get no tables (perhaps because the page wasn't retrieved correctly), then `tables[0]` will fail, raising an error that stops the entire scraper. In a large scraping operation, this could halt lots of work in progress. -* If we get more tables than 1, we should review that we've got the right data. Maybe the web site's owners have changed how the page is structured and put some other part of the page in a table which our CSS selector then inadvertently captures. -* If we get no year URLs, then we've failed our task. - -Here we just use `print` output as a way to report if something went wrong. - -> ## Advanced challenge: Validate `year` -> If the page changes and the year text is not a valid number, we'd like to know about that. -> Write code that validates the year text as being a four-digit number, and does not add a year with invalid text to `out`. -> -> > ## Solution -> > Insert at the TODO above: -> > ~~~ -> > if len(year) != 4 or not year.isdigit(): -> > print("Link text '{}' is not an integer".format(link.text_content())) -> > continue -> > ~~~ -> > {: .python} -> {: .solution} -{: .challenge} - -> ## When the URLs to scrape can't be listed -> Sometimes you can list the pages needed to be scraped in advance. Here we can just generate URLs for all years from 1946 until now. -> Often building a scraper involves analysing the kinds of URLs on a web site and constructing a list of them programmatically. -> -> On the other hand, sometimes you cannot get all the URLs at once, for instance when you need to click a "next page" link (although sometimes these URLs can also be enumerated by identifying patterns in the next page URLs). This means you can't design your scraper with distinct "collect URLs" and "scrape each URL" phases. Instead you might _add each URL to a queue for later processing_. (A scraping framework like Scrapy manages this queuing for you.) -{: .callout} - -We have a list of year pages to scrape. Now we need to scrape the resolutions off each year page. - -# Scraping a page of UNSC resolutions - -At the heart of `get_resolutions_for_year` is getting a record (a row in the output CSV) for each resolution that contains its details. -Looking at [2016](http://www.un.org/en/sc/documents/resolutions/2016.shtml), we want: - -* `symbol`: the text of the first column -* `url`: the link `href` attribute from the first column -* `date`: the text of the second column -* `title`: the text of the third column - -However, for earlier years such as [1999](http://www.un.org/en/sc/documents/resolutions/1999.shtml), the date column is not provided, and we want: - -* `symbol`: the text of the first column -* `url`: the link `href` attribute from the first column -* `date`: the year determined from `get_year_urls` -* `title`: the text of the second column - -We have a few choices in how to code this up, too: - -1. Match all the symbols with one CSS selector evaluated over the document; match all the titles with another selector; merge them together. -2. Match all the symbols' elements with one CSS selector, then iterate over its subsequent sibling elements to get the other fields. -3. Match all the row elements with one CSS selector, then use a CSS selector within it to get each field. -4. Match all the row elements with one CSS selector, then use the element's `.getchildren(...)` to get each field's `<td>` element. - -We will take the last approach. Let's assume that the code for extracting `table` is basically the same as in `get_year_urls`: - -~~~ -import requests -import lxml.html - -def get_resolutions_for_year(year_url, year): - """Return a list of resolutions - - Each should be represented as a dict like:: - - {'date': ..., 'symbol': ..., 'url': ..., ''title': ..., } - """ - response = requests.get(year_url) - tree = lxml.html.fromstring(response.text) - tables = tree.cssselect('#content > table') - # Check you captured something and not more than you expected - if len(tables) != 1: - print('Expected exactly 1 table, got {}'.format(len(tables))) - return [] - table = tables[0] - out = [] - - for row_elem in table.cssselect('tr'): - resolution = {} - # TODO: extract data for each resolution - out.append(resolution) - - # Check we got something - if not out: - print('Expected some resolutions, got none'.format(year)) - return out - - -# Test get_resolutions_for_year on 2016 -resolutions = get_resolutions_for_year("http://www.un.org/en/sc/documents/resolutions/2016.shtml", "2016") -for resolution in resolutions: - print(resolution) -~~~ -{: .python} - -We added: - -* a loop over each row, being a `<tr>` element; -* some code at the end to test if our scraper-in-progress is working. - -> ## Limit the number of URLs to scrape through while debugging -> -> Eventually, we want our scraper to apply its extraction to all pages of UNSC resolutions. -> But while we're working through to the final code that will allow us -> the extract the data we want from those pages, we only want to run it on one -> or a few pages at a time. -> -> This will not only run faster and allow us to iterate more quickly between different -> revisions of our code. It will also not burden the server too much while we're debugging. -> This is probably not such an issue for only tens of pages, but it's good -> practice, as it can make a difference for larger scraping projects. If you are planning -> to scrape a massive website with thousands of pages, it's better to start small. Other -> visitors to that site will thank you for respecting their legitimate desire to access -> it while you're debugging your scraper... -> -> If you have a list of URLs to scrape, such as the output from `get_year_urls()`, -> you might simply slice that list. -> In Python, lists can be _sliced_ using the `list[start:end]` where `start` and `end` are numbers, either of which can be left out: -> -> ~~~ -> list[start:end] # items from start through end-1 -> list[start:] # items from start through the rest of the array -> list[:end] # items from the beginning through end-1 -> list[:] # all items -> ~~~ -> {: .source} -> -> Thus `list[:5]` will get the first five elements from `list`. -{: .callout} - - -The TODO above needs to be filled in with code to get the HTML elements corresponding to `symbol`, `date` (where present) and `title`, and extracting their text. - -Running that script as it is will download the page and print an empty dict for each resolution: - -~~~ -{} -{} -{} -{} -{} -{} -{} -... -~~~ -{: .output} - -Let's start filling in the TODO above, extracting the symbol text for each resolution: - -~~~ - children = row_elem.getchildren() - resolution['symbol'] = children[0].text_content() -~~~ -{: .python} - -This gets the first child of the row, i.e. its first cell, extracts its text, and places it in the resolution dict with the key `"symbol"`. Run the script and check the output. We see: - -~~~ -{'symbol': 'Resolutions adopted by the Security Council \r\n in 2016'} -{'symbol': 'S/RES/2336 \r\n (2016)'} -{'symbol': 'S/RES/2335 \r\n (2016)'} -{'symbol': 'S/RES/2334 \r\n (2016)'} -{'symbol': 'S/RES/2333 \r\n (2016)'} -{'symbol': 'S/RES/2332 \r\n (2016)'} -{'symbol': 'S/RES/2331 \r\n (2016)'} -~~~ -{: .output} - -> ## Challenge: Identify two issues in that output -> There are two problems in the output above. What are they? -> -> > ## Solution -> > 1. The header has been included. -> > 2. The symbols surprisingly have `" \r\n      "` in them. -> {: .solution} -{: .challenge} - -## Cleaning the symbols - -We can exclude the header with: - -~~~ - if len(children) == 1: - # Assume that a row with 1 element is the header - continue -~~~ -{: .python} - -Another approach would be to replace `table.cssselect('tr')` with `table.cssselect('tr')[1:]` to ignore the first row returned by the selector. - -To clean up the messy symbols, we have to realise that `"\r\n"` are special in Python: they indicate a line break (like pressing enter) in text. So what we have here is a sequence of _white-space characters_ including `"\r"`, `"\n"`, and `" "`. In HTML, a sequence of white-space characters is usually interpreted as a single space. The following substitutes a single space for any white-space sequence in retrieving an element's text. - -~~~ -def clean_text(element): - all_text = element.text_content() - cleaned = ' '.join(all_text.split()) - return cleaned -~~~ -{: .python} - -Make these two changes and run the script again to check it's working better. - -## Extracting other fields - -We can handle the fact that a date column may or may not be present with: - -~~~ - if len(children) == 3: - # there is a date column - resolution['date'] = clean_text(children[1]) - elif len(children) == 2: - # adopt the year for the page - resolution['date'] = year - else: - print('Unexpected number of children in row element: {}'.format(len(children))) - continue -~~~ -{: .python} - -Run this on 2016 and 1999 to check that the output is sensibly getting 'symbol' and 'date' whether or not the date column is available. - -> ## Challenge: fill in the `title` and `url` fields -> -> The URL extraction requires finding the `<a>` element within the symbol cell and extracting its attribute, as in `get_year_urls` above. -> -> The title text can be extracted like the other fields, except that it is sometimes the second and sometimes the third (but always the last) column. -> -> Hint: You can get the last element of a Python list with `[-1]`. The CSS selectors `:nth-last-child(1)` and `:nth-last-of-type(1)` fulfill a similar purpose. -> -> > ## Solution -> > ~~~ -> > symbol_links = children[0].cssselect('a') -> > if len(symbol_links) != 1: -> > print('Expected 1 link in the symbol column, got {}'.format(len(symbol_links))) -> > continue -> > relative_url = symbol_links[0].attrib['href'] -> > resolution['url'] = requests.compat.urljoin(response.url, relative_url) -> > resolution['title'] = clean_text(children[-1]) -> > ~~~ -> > {: .python} -{: .challenge} - -# Putting it all together - -All we appear to need now is write some code to call `get_resolutions_for_year` for each year, and use Python's standard `csv` module to change our dicts into CSV. This code can replace the "Test get_resolutions_for_year on 2016" code and drive the overall scraper. - -~~~ -import csv -import time - -with open('unsc-resolutions.csv', 'w') as out_file: - writer = csv.DictWriter(out_file, ['date', 'symbol', 'title', 'url']) - writer.writeheader() - - # Loop over years - for year_url, year in get_year_urls(): - time.sleep(0.1) # Wait a moment - - print('Processing:', year_url) - year_resolutions = get_resolutions_for_year(year_url, year) - - for resolution in year_resolutions: - writer.writerow(resolution) -~~~ -{: .python} - -Some explanation: - -* `with open(...) as out_file` opens a file for writing and calls it `out_file`. Using `with` ensures that the file is closed, whether the `with` block is ended by completion or by error. -* `csv.DictWriter(...)` constructs a writer which converts dicts with the specified fields to a comma-delimited table (CSV) and writes it to `out_file`. -* `writer.writeheader()` writes the line `date,symbol,title,url` at the top of the CSV. -* `for year_url, ...` begins to iterate over the year URLs acquired from `get_year_urls()`. -* `time.sleep(0.1)` instructs Python to wait for 10% of a second before downloading the next page. This helps to avoid placing too much strain on the `www.un.org` web server. -* `print('Processing', ...)` tells you which year the scraper is scraping. It is very valuable to have this knowledge when you need to work out why some other error message was printed. -* `year_resolutions = ...` gets the resolutions for the current year in the loop. -* `writer.writerow(resolution)` converts the resolution to a line of CSV and outputs it. - -You have a full scraper. But does it perfectly capture the data? - -## Quirks and quality assurance - -Run the above scraper. Do our `print` statements highlight any quirks in the web site? - -Open the output (`unsc-resolutions.csv`) in a spreadsheet program like Microsoft Excel. Can you identify any other quirks from the data? - -> ## Challenge: debug the issues -> Your scraper should have reported: -> -> * "Expected 1 link in the symbol column, got 0" in [2013](http://www.un.org/en/sc/documents/resolutions/2013.shtml); -> * "Expected exactly 1 table, got 2" in [1964](http://www.un.org/en/sc/documents/resolutions/1964.shtml) and [1960](http://www.un.org/en/sc/documents/resolutions/1960.shtml); and -> * "Expected some resolutions, got none" in [1959](http://www.un.org/en/sc/documents/resolutions/1964.shtml). -> -> View those pages (you should not need to view the source) to identify the associated issues: how are those pages different from the ones you initially designed your scraper for? -> Then fix the scraper to get the complete, clean dataset. -> -> > ## Solution -> > 1. 2013 has a header row above the data. Because our scraper already skips the row when there is no link in it, the data is clean. We could modify our scraper to silence the error in this year: -> > ~~~ -> > if len(symbol_links) != 1: -> > if year != '2013': -> > print('Expected 1 link in the symbol column, got {}'.format(len(symbol_links))) -> > continue -> > ~~~ -> > {: .python} -> > 2. 1964 and 1960 have the page duplicated! -> > -> > Replace: -> > ~~~ -> > if len(tables) != 1: -> > print('Expected exactly 1 table, got {}'.format(len(tables))) -> > return [] -> > ~~~ -> > {: .python} -> > With: -> > ~~~ -> > if not tables: -> > print('Expected 1 table, got none') -> > return [] -> > if len(tables) > 1: -> > print('Taking first of {} tables'.format(len(tables))) -> > return [] -> > ~~~ -> > 3. Our system correctly identifies that there are no resolutions in 1959. We could modify our scraper to silence the error in this year: -> > ~~~ -> > if year != '1959': -> > print('Expected some resolutions, got none'.format(year)) -> > ~~~ -> > {: .python} -> {: .solution} -{: .challenge} - -In constructing this lesson, we identified several quirks in the data, where one year differed from another in surprising ways (and there may be more we have not identified!). We have discussed many of these: - -* In the [index page](http://www.un.org/en/sc/documents/resolutions/), most links to year pages have relative URLs like `1980.shtml`, but some are like `/en/sc/documents/resolutions/2015.shtml`. Without `urljoin` we could have easily made a mistake finding the page URLs. -* Some years have a date column, while most do not. -* One year has a header row, giving names describing each column, while others do not. -* Two years duplicate the entire page's HTML. If we had not checked for the case of extracting multiple tables, we might only have noticed the issue from the data, perhaps by plotting the counts per year and seeing an outlying count in 1960, or by noticing duplicate records. -* In some years, such as [2017](http://www.un.org/en/sc/documents/resolutions/), not all `<tr>` opening tags have a matching `</tr>` closing tag. At one time we also found an excess `</tr>`. Alternatives to lxml may behave differently with such errors. Python's `html.parser` simply ignored the rest of the page's content when it reached the excess `</tr>`, discarding subsequent resolution data. -* White-space in the resolution symbols differs from year to year. We found: `"S/RES/1939  (2010)"` vs. `"S/RES/2025 (2011)"` vs. `"S/RES/2132\n       (2013)"` - -These quirks are somewhat peculiar to web sites that are _manually edited_. However, similar things can happen with database-backed web sites. For instance: - -* some fields may be absent, causing your XPath/CSS selectors to return empty or capture the wrong piece of data; -* the HTML may differ for different categories of object (e.g. films vs. TV shows); -* historical data may not be presented like recent data; -* the template may change between different runs of the scraper; or -* the web site may return an error page, or may identify your scraper as malicious and refuse to continue serving you content. - -> ## Tips for quirk resilience -> Here are some tips about how you could ensure that your scraper will work despite variation. -> -> 1. Look at your scraped data. Look at it more closely. Look at random samples collected over time. Perhaps analyse it in a tool like OpenRefine which will show you the number of distinct/duplicated values in each column. If you are scraping data over a long time, keep a dashboard of diagnostic measures to show you how many fields come back blank, for instance. -> 2. Think about cases where your scraper might fail, and apprehend them in code. Validate the extractions in your code. When something differs from expectation, output an informative message onto a log. Make sure the log includes enough information about the context, e.g. which page or part of the page you are scraping at the time. -> 3. Only allow an error to halt your scraping operation if that's really necessary, by wrapping your main scraper code in an exception handler. For example: -> ~~~ -> print('Processing:', year_url) -> try: -> year_resolutions = get_resolutions_for_year(year_url, year) -> except Exception: -> # the exception has been caught instead of Python exiting -> print('ERROR while processing', year, ':') -> import traceback -> traceback.print_exc() # describe the error and what code triggered it -> continue # skip to the next year -> ~~~ -> {: .python} -> Consider this a last resort: if an error occurs, any resolutions scraped from the error year will not be output. -> 4. Write helper functions to make cleaning and error identification easy for you. `clean_text` is one example. Another useful helper might be: -> ~~~ -> def extract_one(list_of_extractions, default=None): -> if len(list_of_extractions) == 0: -> print('Expected some extractions, but got None') -> return default -> if len(list_of_extractions) > 1: -> print('Expected 1 extraction, but got {}'.format(len(list_of_extractions))) -> return list_of_extractions[0] -> ~~~ -> {: python} -> As well as alerting you to more than one extraction, this avoids triggering an error if your `cssselect` or `xpath` query returns an empty list. -> -> A specialised framework like Scrapy helps manage tasks like logging, diagnostics, and handling empty lists of extractions. -{: .callout} - -## Using the data - -> ## Challenge: Analyse the data -> -> Perform some interesting analysis of the data, for instance: -> -> * Plot the number of resolutions per year. Are there interesting periods of increase or lull? -> * Count how often each title occurs. -> * Identify which words are most frequent in the titles. -> * Plot only those resolutions that pertain to membership vs those that do not. -> * Plot only those resolutions mentioning some country of choice (e.g. Israel or Pakistan) in their title. -> * Very advanced: lookup strings of capitalised words (optionally including lowercase words like "of" and "for") in the Wikipedia or Wikidata API to associate the names with locations. Plot them on a map! -> -> A Pivot Table will be very useful for performing these analyses in Excel or Google Sheets. Similar functionality is provided in Python by [Pandas](http://pandas.pydata.org) and its `pivot` and `groupby` functionality. -{: .challenge} - -> ## Extension challenge: multilingual UNSC resolutions -> Run the scraper on resolutions in Arabic (start at http://www.un.org/ar/sc/documents/resolutions/) or Chinese (start at http://www.un.org/zh/sc/documents/resolutions/) and merge the results with English to have columns `en_title`, `ar_title`, etc. -> -> Hint: a tool for tabular data, [`pandas`](http://pandas.pydata.org) can read in CSV (`pandas.read_csv`) and can merge together multiple tables on the basis of some matching keys (`pandas.concat`). -{: .challenge} - -While here we have extracted data that was already in tables into another tabular format, very often what we're processing doesn't look like a table on the web site. But the procedure is the same: identify the elements that you wish to extract, and apply a pattern which selects them from the HTML. - -You are now ready to write your own scrapers! - -# Advanced topics and resources - -Aside from ethical questions addressed in the next episode, below are a number of advanced topics related to building a web scraper. Most are features of existing specialised scraping frameworks, such as Scrapy, or commercial scraping tools. - -* __Caching and offline scraping__: - If you are expecting to scrape the same page many times, for instance while designing and debugging your scraper, it may be a good idea to download part or all of the web site to your own computer in advance of scraping it, so that you do not need to make repeated requests to the web server. Not only does this reduce the load on the web server, but it means the scraping is limited only by the speed of your scraper, not the speed at which you download the data. Some scraping frameworks may offer such caching out of the box; otherwise this involves using one of many existing tools to download a local copy of some web site, or writing the `requests` part of your scraper as a separate process that saves the pages in a database or files on your machine. -* __Scraping many pages at once__: - Some pages cannot be scraped until another is done. For instance, you may not be able to scrape a listing of resolutions until you know that page exists by looking at the index page. - But in many cases, multiple pages can be scraped at the same time (as long as doing so does not make too many requests to the same server in a short period). Doing so can make the scraping process faster. - Scraping frameworks may offer the ability to process pages _in parallel_ (or _asynchronously_). - If you take advantage of this feature, make sure to be careful how you log messages about issues with the scrape, or it might be hard to tell which page it came from. -* __Periodic scraping__: - One of web scraping's benefits is its ability to collect data from some web site as it changes over time (assuming the page content changes, but not the page structure). Scrapers can be set up to run periodically. -* __Running the scraper on the cloud__: - You may not want to leave your own computer on to scrape. It may take resources away from your work, for instance. Commercial scrapers offer to run your scraper on their machines. A free alternative is [morph.io](http://morph.io) which offers to host your open-source scraper in the cloud and return the data to you. -* __Alternative output formats__: Some structures of information are not suitable to put into a table; others are too big to store in a single table. Scraping frameworks may support storing the scraped data in a database or some other structure. -* __Data only accessible through interaction__: Sometimes a web site requires logging in, or you only get access to the data by clicking on or scrolling down the page. While particular cases may be engineered with a traditional `requests`-based scraper, an alternative is to employ a _web driver_. This is a web browser that is controlled by a program instead of a human, and will naturally run scripts associated with a web page, but can also do things like clicking, scrolling, etc. Emulating a human's interactions can give your scraper access to everything a human can get. The [Web Scraping Sandbox, toscrape.com](http://toscrape.com/) includes several variants of the same artificial web site, including with login forms and "infinite scroll"s that require this kind of scraper. Challenge yourself to scraping the data on that site! - -> ## So why didn't we learn Scrapy? -> Scrapy provides a great framework for designing, implementing and managing robust and efficient scrapers. However, we get the sense that people who are not very experienced at programming find the declarative paradigm facilitated by Scrapy very foreign. -> -> On the other hand, writing a more *procedural* scraper as we have here with the nuts and bolts of `requests` and `lxml` helps to motivate some of the issues that Scrapy endeavours to solve or ameliorate. -{: .callout} - -# Reference - -* [requests documentation](http://docs.python-requests.org/en/master/) -* [lxml documentation](http://lxml.de/api.html) -* [Scrapy documentation](https://scrapy.org/) diff --git a/_extras/scrapy.md b/_episodes/04-scrapy.md old mode 100644 new mode 100755 similarity index 99% rename from _extras/scrapy.md rename to _episodes/04-scrapy.md index 8f87d5a..a1f2945 --- a/_extras/scrapy.md +++ b/_episodes/04-scrapy.md @@ -1,6 +1,4 @@ --- -permalink /scrapy/ -layout: episode title: "Web scraping using Python and Scrapy" teaching: 90 exercises: 30 diff --git a/_episodes/05-conclusion.md b/_episodes/05-conclusion.md old mode 100644 new mode 100755 index b89f954..c03b881 --- a/_episodes/05-conclusion.md +++ b/_episodes/05-conclusion.md @@ -1,7 +1,7 @@ --- -title: "Discussion" +title: "Conclusion" teaching: 15 -exercises: 0 +exercises: 15 questions: - "When is web scraping OK and when is it not?" - "Is web scraping legal? Can I get into trouble?" @@ -17,13 +17,14 @@ keypoints: - "Be nice. In doubt, ask." --- -Now that we have seen several ways to scrape data from websites, -we may ask ourselves whether +Now that we have seen several different ways to scrape data from websites and are +ready to start working on potentially larger projects, we may ask ourselves whether there are any legal implications of writing a piece of computer code that downloads information from the Internet. -In this section, we will discuss some issues to be aware of when -scraping websites, and will establish a [scraping code of conduct (below)](#web-scraping-code-of-conduct). +In this section, we will be discussing some of the issues to be aware of when +scraping websites, and we will establish a [code of conduct (below)](#web-scraping-code-of-conduct) +to guide our web scraping projects. > ## This section does not constitute legal advice > @@ -54,7 +55,7 @@ from accessing the site during that time, or even cause the server to run out of In fact, this is such an efficient way to disrupt a web site that hackers are often doing it on purpose. This is called a [Denial of Service (DoS) attack](https://en.wikipedia.org/wiki/Denial-of-service_attack). -Since DoS attacks are unfortunately a common occurrence on the Internet, modern web servers include +Since DoS attacks are unfortunately a common occurence on the Internet, modern web servers include measures to ward off such illegitimate use of their resources. They are watchful for large amounts of requests appearing to come from a single computer or IP address, and their first line of defense often involves refusing any further requests coming from this IP address. @@ -63,31 +64,34 @@ A web scraper, even one with legitimate purposes and no intent to bring a websit similar behaviour and, if we are not careful, result in our computer being banned from accessing a website. -The good news is that good web scraping tools recognize that this is a risk and include +The good news is that a good web scraper, such as Scrapy, recognizes that this is a risk and includes measures to prevent our code from appearing to launch a DoS attack on a website. This is mostly done by inserting a random delay between individual requests, which gives the target server enough time to handle requests from other users between ours. -It is also a good idea to avoid scraping many pages repeatedly in a short period of time. -So, for instance, while still writing and debugging a scraper, it is good practice to limit the number of pages we scrape. -Or, once we know which pages contain the data we need, we can download all of them once, and develop a scraper for the specific data we need on the downloaded copies. +This is Scrapy's default behaviour, and it should prevent most scraping projects from ever causing problems. +To be on the safe side, however, it is good practice to limit the number of pages we are scraping +while we are still writing and debugging our code. This is why in the previous section, we imposed +a limit of five pages to be scraped, which we only removed when we were reasonably certain the scraper +was working as it should. -Checking that our scraper stays on task, for instance by checking that we never download a URL on an unfamiliar site, is another way to make sure our code is not going to start scraping the entire Internet by mistake. +Limiting requests to a particular domain, by using Scrapy's `allowed_domains` property is another +way to make sure our code is not going to start scraping the entire Internet by mistake. -Thanks to the defences web servers use to protect themselves against DoS attacks and scraping tools' -measures to avoid inadvertently launching such an attack, the risks of causing trouble is limited. +Thanks to the defenses web servers use to protect themselves against DoS attacks and Scrapy's +measure to avoid inadvertently launching such an attack, the risks of causing trouble is limited. ## Don't steal: Copyright and fair use -In certain circumstances web scraping _can_ be illegal. If the terms +It is important to recognize that in certain circumstances web scraping _can_ be illegal. If the terms and conditions of the web site we are scraping specifically prohibit downloading -and copying its content, then we could get in trouble for scraping it. +and copying its content, then we could be in trouble for scraping it. In practice, however, web scraping is a tolerated practice, provided reasonable care is taken not to disrupt the "regular" use of a web site, as we have seen above. In a sense, web scraping is no different than using a web browser to visit a web page, -in that it amounts to using computer software (a browser vs a scraper) to access +in that it amounts to using computer software (a browser vs a scraper) to acccess data that is publicly available on the web. In general, if data is publicly available (the content that is being scraped is not @@ -95,10 +99,10 @@ behind a password-protected authentication system), then it is OK to scrape it, provided we don't break the web site doing so. What is potentially problematic is if the scraped data will be shared further. For example, downloading content off one website and posting it on another website (as our own), unless -explicitly permitted, would constitute copyright violation and be illegal. +explicitely permitted, would constitute copyright violation and be illegal. However, most copyright legislations recognize cases in which reusing some, possibly -copyrighted, information in an aggregate or derivative form is considered +copyrighted, information in an aggregate or derivative format is considered "fair use". In general, unless the intent is to pass off data as our own, copy it word for word or trying to make money out of it, reusing publicly available content scraped off the internet is OK. @@ -119,28 +123,21 @@ will help you sort out the legal aspects of your project. The university library is often the best place to start looking for help on copyright. -### Robots Exclusion Standard - -If your scraper involves visiting large portions of a web site, it may be -appropriate to adhere to the [robots.txt standard](https://en.wikipedia.org/wiki/Robots.txt) -which allows web scrapers to specify parts of their site that should not be -indexed by web search. - -`robots.txt` has no legal standing, but it is a matter of etiquette that, -when broken, could lead a site administrator to block your scraper. - ## Be nice: ask and share -Depending on the scope of your project, it might be worthwhile asking +Depending on the scope of your project, it might be worthwhile to consider asking the owners or curators of the data you are planning to scrape if they have it -available in a structured format. Not only could this save you the trouble of -writing a scraper, but it might help clarify straight away what you can and cannot do -with the data, or if your work is of interest to them. +already available in a structured format that could suit your project. If your +aim is do use their data for research, or to use it in a way that could potentially +interest them, not only it could save you the trouble of writing a +web scraper, but it could also help clarify straight away what you can and cannot do +with the data. On the other hand, when you are publishing your own data, as part of a research project, -documentation or a public website, you might want to think about the most helpful way -to share it: try to provide others with a way to download your raw data in a structured -format, and thus save them the trouble of scraping your own pages! +documentation or a public website, you might want to think about whether someone might +be interested in getting your data for their own project. If you can, try to provide +others with a way to download your raw data in a structured format, and thus save +them the trouble to try and scrape your own pages! ## Web scraping code of conduct @@ -160,7 +157,7 @@ be fine. investigating something like that. 3. __Check your local legislation.__ For example, certain countries have laws protecting personal information such as email addresses and phone numbers. Scraping such information, - even from publicly available web sites, can be illegal (e.g. in Australia). + even from publicly avaialable web sites, can be illegal (e.g. in Australia). 4. __Don't share downloaded content illegally.__ Scraping for personal purposes is usually OK, even if it is copyrighted information, as it could fall under the fair use provision of the intellectual property legislation. However, sharing data for which you don't @@ -174,7 +171,7 @@ be fine. requests per second. If you are writing a recursive scraper (i.e. that follows hyperlinks), test it on a smaller dataset first to make sure it does what it is supposed to do. Adjust the settings of your scraper to allow for a delay between - requests. + requests. By default, Scrapy uses conservative settings that should minimize this risk. 7. __Publish your own data in a reusable way.__ Don't force others to write their own scrapers to get at your data. Use open and software-agnostic formats (e.g. JSON, XML), provide metadata (data about your data: where it came from, what it represents, how @@ -184,9 +181,9 @@ be fine. ## Going further This lesson only provides an introduction to the practice of web scraping and highlights -some of the tools available. You might want to try out a commercial visual scraper or -an open-source scraping framework (such as [Scrapy](https://doc.scrapy.org/en/latest/) in Python) -in the programming language of your choice. If you're not sure what to scrape, a practice site such as [toscrape.com](http://toscrape.com) will provide some further challenges. +some of the tools available. Scrapy has many more features than those mentioned in the +previous section, be sure to refer to its [full documentation](https://doc.scrapy.org/en/latest/) +for details. Happy scraping! @@ -212,5 +209,5 @@ Happy scraping! followed indepentently. This lesson is heavily inspired by Software Carpentry. * [Data Carpentry](http://www.datacarpentry.org/) is a sister organisation of Software Carpentry focused on the fundamental data management skills required to conduct research. -* [Library Carpentry](https://librarycarpentry.github.io/) is another Software Carpentry spin-off +* [Library Carpentry](https://librarycarpentry.github.io/) is another Software Carpentry spinoff focused on software skills for librarians. diff --git a/_episodes_rmd/.gitkeep b/_episodes_rmd/.gitkeep old mode 100644 new mode 100755 diff --git a/_episodes_rmd/data/.gitkeep b/_episodes_rmd/data/.gitkeep old mode 100644 new mode 100755 diff --git a/_extras/.gitkeep b/_extras/.gitkeep old mode 100644 new mode 100755 diff --git a/_extras/about.md b/_extras/about.md old mode 100644 new mode 100755 diff --git a/_extras/cloudservices.md b/_extras/cloudservices.md old mode 100644 new mode 100755 diff --git a/_extras/discuss.md b/_extras/discuss.md old mode 100644 new mode 100755 index 59d9cf4..1d467a4 --- a/_extras/discuss.md +++ b/_extras/discuss.md @@ -3,8 +3,4 @@ layout: page title: Discussion permalink: /discuss/ --- -There are many ways to discuss Library Carpentry lessons: - -- Join our [Gitter discussion forum]({{ site.contact }}). -- Follow updates on [Twitter](https://twitter.com/LibCarpentry). -- Make a suggestion or correct an error by [raising an Issue]({{site.github.repository_url}}/issues). +FIXME diff --git a/_extras/figures.md b/_extras/figures.md old mode 100644 new mode 100755 diff --git a/_extras/guide.md b/_extras/guide.md old mode 100644 new mode 100755 index 16a4e8f..0bad995 --- a/_extras/guide.md +++ b/_extras/guide.md @@ -3,16 +3,4 @@ layout: page title: "Instructor Notes" permalink: /guide/ --- - -____ -# Tips and Tricks - -____ -## Making a handout - -Librarians like handouts. To make a handout for this lesson, adapt/print from [http://data-lessons.github.io/library-webscraping/reference/]([http://data-lessons.github.io/library-webscraping/reference/). - -_____ -# General notes on web scraping - -Coming soon! +FIXME diff --git a/_extras/importio.md b/_extras/importio.md old mode 100644 new mode 100755 diff --git a/_extras/xpath-cheatsheet.md b/_extras/xpath-cheatsheet.md old mode 100644 new mode 100755 diff --git a/_extras/xpath-cheatsheet.md.pdf b/_extras/xpath-cheatsheet.md.pdf old mode 100644 new mode 100755 diff --git a/_includes/all_figures.html b/_includes/all_figures.html old mode 100644 new mode 100755 diff --git a/_includes/all_keypoints.html b/_includes/all_keypoints.html old mode 100644 new mode 100755 diff --git a/_includes/carpentries.html b/_includes/carpentries.html old mode 100644 new mode 100755 index a0e0181..69e2e1c --- a/_includes/carpentries.html +++ b/_includes/carpentries.html @@ -1,6 +1,3 @@ -{% comment %} - General description of Software and Data Carpentry. -{% endcomment %} <div class="row"> <div class="col-md-2" align="center"> <a href="{{ site.swc_site }}"><img src="{{ page.root }}/assets/img/swc-icon-blue.svg" alt="Software Carpentry logo" /></a> @@ -26,19 +23,5 @@ building on learners' existing knowledge to enable them to quickly apply skills learned to their own research. </div> </div> -<br/> -<div class="row"> - <div class="col-md-2" align="center"> - <a href="{{ site.lc_site }}"><img src="{{ page.root }}/assets/img/lc-icon-black.svg" alt="Library Carpentry logo" /></a> - </div> - <div class="col-md-8"> - Library Carpentry is made by librarians to help librarians - automate repetitive, boring, error-prone tasks; - create, maintain and analyse sustainable and reusable data; - work effectively with IT and systems colleagues; - better understand the use of software in research; - and much more. - Library Carpentry was the winner of the 2016 - <a href="http://labs.bl.uk/British+Library+Labs+Awards">British Library Labs Teaching and Learning Award</a>. - </div> -</div> + + diff --git a/_includes/dc/intro.html b/_includes/dc/intro.html deleted file mode 100644 index 741aeeb..0000000 --- a/_includes/dc/intro.html +++ /dev/null @@ -1,18 +0,0 @@ -<p> - <a href="{{site.dc_site}}">Data Carpentry</a> - aims to help researchers get their work done - in less time and with less pain - by teaching them basic research computing skills. - This hands-on workshop will cover basic concepts and tools, - including program design, version control, data management, - and task automation. - Participants will be encouraged to help one another - and to apply what they have learned to their own research problems. -</p> -<p align="center"> - <em> - For more information on what we teach and why, - please see our paper - "<a href="http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1001745">Best Practices for Scientific Computing</a>". - </em> -</p> diff --git a/_includes/dc/schedule.html b/_includes/dc/schedule.html deleted file mode 100644 index 6894a19..0000000 --- a/_includes/dc/schedule.html +++ /dev/null @@ -1,24 +0,0 @@ -<div class="row"> - <div class="col-md-6"> - <h3>Day 1</h3> - <table class="table table-striped"> - <tr> <td>09:00</td> <td>Automating tasks with the Unix shell</td> </tr> - <tr> <td>10:30</td> <td>Coffee</td> </tr> - <tr> <td>12:00</td> <td>Lunch break</td> </tr> - <tr> <td>13:00</td> <td>Building programs with Python</td> </tr> - <tr> <td>14:30</td> <td>Coffee</td> </tr> - <tr> <td>16:00</td> <td>Wrap-up</td> </tr> - </table> - </div> - <div class="col-md-6"> - <h3>Day 2</h3> - <table class="table table-striped"> - <tr> <td>09:00</td> <td>Version control with Git</td> </tr> - <tr> <td>10:30</td> <td>Coffee</td> </tr> - <tr> <td>12:00</td> <td>Lunch break</td> </tr> - <tr> <td>13:00</td> <td>Managing data with SQL</td> </tr> - <tr> <td>14:30</td> <td>Coffee</td> </tr> - <tr> <td>16:00</td> <td>Wrap-up</td> </tr> - </table> - </div> -</div> diff --git a/_includes/dc/syllabus.html b/_includes/dc/syllabus.html deleted file mode 100644 index a325cee..0000000 --- a/_includes/dc/syllabus.html +++ /dev/null @@ -1,96 +0,0 @@ -<div class="row"> - <div class="col-md-6"> - <h3 id="syllabus-shell">The Unix Shell</h3> - <ul> - <li>Files and directories</li> - <li>History and tab completion</li> - <li>Pipes and redirection</li> - <li>Looping over files</li> - <li>Creating and running shell scripts</li> - <li>Finding things</li> - <li><a href="{{site.swc_pages}}/shell-novice/reference/">Reference...</a></li> - </ul> - </div> - <div class="col-md-6"> - <h3 id="syllabus-python">Programming in Python</h3> - <ul> - <li>Using libraries</li> - <li>Working with arrays</li> - <li>Reading and plotting data</li> - <li>Creating and using functions</li> - <li>Loops and conditionals</li> - <li>Defensive programming</li> - <li>Using Python from the command line</li> - <li><a href="{{site.swc_pages}}/python-novice-inflammation/reference/">Reference...</a></li> - </ul> - </div> - <!-- - <div class="col-md-6"> - <h3 id="syllabus-r">Programming in R</h3> - <ul> - <li>Working with vectors and data frames</li> - <li>Reading and plotting data</li> - <li>Creating and using functions</li> - <li>Loops and conditionals</li> - <li>Using R from the command line</li> - <li><a href="{{site.swc_pages}}/r-novice-inflammation/reference/">Reference...</a></li> - </ul> - </div> - --> - <!-- - <div class="col-md-6"> - <h3 id="syllabus-matlab">Programming in MATLAB</h3> - <ul> - <li>Working with arrays</li> - <li>Reading and plotting data</li> - <li>Creating and using functions</li> - <li>Loops and conditionals</li> - <li>Defensive programming</li> - <li><a href="{{site.swc_pages}}/matlab-novice-inflammation/reference/">Reference...</a></li> - </ul> - </div> - --> -</div> - -<div class="row"> - <div class="col-md-6"> - <h3 id="syllabus-git">Version Control with Git</h3> - <ul> - <li>Creating a repository</li> - <li>Recording changes to files: <code>add</code>, <code>commit</code>, ...</li> - <li>Viewing changes: <code>status</code>, <code>diff</code>, ...</li> - <li>Ignoring files</li> - <li>Working on the web: <code>clone</code>, <code>pull</code>, <code>push</code>, ...</li> - <li>Resolving conflicts</li> - <li>Open licenses</li> - <li>Where to host work, and why</li> - <li><a href="{{site.swc_pages}}/git-novice/reference/">Reference...</a></li> - </ul> - </div> - <!-- - <div class="col-md-6"> - <h3 id="syllabus-sql">Managing Data with SQL</h3> - <ul> - <li>Reading and sorting data</li> - <li>Filtering with <code>where</code></li> - <li>Calculating new values on the fly</li> - <li>Handling missing values</li> - <li>Combining values using aggregation</li> - <li>Combining information from multiple tables using <code>join</code></li> - <li>Creating, modifying, and deleting data</li> - <li>Programming with databases</li> - <li><a href="{{site.swc_pages}}/sql-novice-survey/reference/">Reference...</a></li> - </ul> - </div> - --> - <div class="col-md-6"> - <h3 id="syllabus-r">Open Refine</h3> - <ul> - <li>Introduction to OpenRefine</li> - <li>Importing data</li> - <li>Basic functions</li> - <li>Advanced Functions</li> - <li><a href="{{site.lc_pages}}library-openrefine/reference">Reference...</a></li> - </ul> - </div> -</div> diff --git a/_includes/dc/who.html b/_includes/dc/who.html deleted file mode 100644 index 2d8e94a..0000000 --- a/_includes/dc/who.html +++ /dev/null @@ -1,8 +0,0 @@ -<p id="who"> - <strong>Who:</strong> - The course is aimed at graduate students and other researchers. - <strong> - You don't need to have any previous knowledge of the tools - that will be presented at the workshop. - </strong> -</p> diff --git a/_includes/episode_break.html b/_includes/episode_break.html old mode 100644 new mode 100755 diff --git a/_includes/episode_keypoints.html b/_includes/episode_keypoints.html old mode 100644 new mode 100755 index 2baa53e..85378a5 --- a/_includes/episode_keypoints.html +++ b/_includes/episode_keypoints.html @@ -1,6 +1,3 @@ -{% comment %} - Display key points for an episode. -{% endcomment %} <blockquote class="keypoints"> <h2>Key Points</h2> <ul> diff --git a/_includes/episode_navbar.html b/_includes/episode_navbar.html old mode 100644 new mode 100755 index b9f85f6..a789d3d --- a/_includes/episode_navbar.html +++ b/_includes/episode_navbar.html @@ -1,11 +1,26 @@ {% comment %} - Navigation bar for an episode. + Find previous and next episodes (if any). +{% endcomment %} +{% for episode in site.episodes %} + {% if episode.url == page.url %} + {% unless forloop.first %} + {% assign prev_episode = prev %} + {% endunless %} + {% unless forloop.last %} + {% assign next_episode = site.episodes[forloop.index] %} + {% endunless %} + {% endif %} + {% assign prev = episode %} +{% endfor %} + +{% comment %} + Display title and prev/next links. {% endcomment %} <div class="row"> <div class="col-md-1"> <h3> - {% if page.previous.url %} - <a href="{{ page.root }}{{ page.previous.url }}"><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span><span class="sr-only">previous episode</span></a> + {% if prev_episode %} + <a href="{{ page.root }}{{ prev_episode.url }}"><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span><span class="sr-only">previous episode</span></a> {% else %} <a href="{{ page.root }}/"><span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span><span class="sr-only">lesson home</span></a> {% endif %} @@ -14,12 +29,13 @@ <h3> <div class="col-md-10"> {% if include.episode_navbar_title %} <h3 class="maintitle"><a href="{{ page.root }}/">{{ site.title }}</a></h3> + <h1 class="maintitle">{{ page.title }}</h1> {% endif %} </div> <div class="col-md-1"> <h3> - {% if page.next.url %} - <a href="{{ page.root }}{{ page.next.url }}"><span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span><span class="sr-only">next episode</span></a> + {% if next_episode %} + <a href="{{ page.root }}{{ next_episode.url }}"><span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span><span class="sr-only">next episode</span></a> {% else %} <a href="{{ page.root }}/"><span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span><span class="sr-only">lesson home</span></a> {% endif %} diff --git a/_includes/episode_overview.html b/_includes/episode_overview.html old mode 100644 new mode 100755 diff --git a/_includes/episode_title.html b/_includes/episode_title.html old mode 100644 new mode 100755 index d0abc65..5b9c821 --- a/_includes/episode_title.html +++ b/_includes/episode_title.html @@ -1,9 +1,42 @@ +{% comment %} + Find previous and next episodes (if any). +{% endcomment %} +{% for episode in site.episodes %} + {% if episode.url == page.url %} + {% unless forloop.first %} + {% assign prev_episode = prev %} + {% endunless %} + {% unless forloop.last %} + {% assign next_episode = site.episodes[forloop.index] %} + {% endunless %} + {% endif %} + {% assign prev = episode %} +{% endfor %} + +{% comment %} + Display title and prev/next links. +{% endcomment %} <div class="row"> <div class="col-md-1"> + <h3> + {% if prev_episode %} + <a href="{{ page.root }}{{ prev_episode.url }}"><span class="glyphicon glyphicon-menu-left"></span></a> + {% else %} + <a href="{{ page.root }}"><span class="glyphicon glyphicon-menu-up"></span></a> + {% endif %} + </h3> </div> <div class="col-md-10"> + <h3 class="maintitle"><a href="{{ page.root }}/">{{ site.title }}</a></h3> <h1 class="maintitle">{{ page.title }}</h1> </div> <div class="col-md-1"> + <h3> + {% if next_episode %} + <a href="{{ page.root }}{{ next_episode.url }}"><span class="glyphicon glyphicon-menu-right"></span></a> + {% else %} + <a href="{{ page.root }}"><span class="glyphicon glyphicon-menu-up"></span></a> + {% endif %} + </h3> </div> </div> diff --git a/_includes/javascript.html b/_includes/javascript.html old mode 100644 new mode 100755 index a2066c2..010ae4a --- a/_includes/javascript.html +++ b/_includes/javascript.html @@ -1,6 +1,3 @@ -{% comment %} - Javascript used in lesson and workshop pages. -{% endcomment %} <script src="{{ page.root }}/assets/js/jquery.min.js"></script> <script src="{{ page.root }}/assets/js/bootstrap.min.js"></script> <script src="{{ page.root }}/assets/js/lesson.js"></script> diff --git a/_includes/lc/intro.html b/_includes/lc/intro.html deleted file mode 100644 index 6794b54..0000000 --- a/_includes/lc/intro.html +++ /dev/null @@ -1,19 +0,0 @@ -<p> - <a href="{{site.lc_site}}">Library Carpentry</a> - is made by librarians, for librarians to help you: -</p> -<ul> - <li>automate repetitive, boring, error-prone tasks</li> - <li>create, maintain and analyse sustainable and reusable data</li> - <li>work effectively with IT and systems colleagues</li> - <li>better understand the use of software in research</li> - <li>and much more...</li> -</ul> -<p align="center"> - <em> - Library Carpentry introduces you to the fundamentals of computing - and provides you with a platform for further self-directed learning. - For more information on what we teach and why, please see our paper - "<a href="http://doi.org/10.18352/lq.10176">Library Carpentry: software skills training for library professionals</a>". - </em> -</p> diff --git a/_includes/lc/schedule.html b/_includes/lc/schedule.html deleted file mode 100644 index cc2b592..0000000 --- a/_includes/lc/schedule.html +++ /dev/null @@ -1,24 +0,0 @@ -<div class="row"> - <div class="col-md-6"> - <h3>Day 1</h3> - <table class="table table-striped"> - <tr> <td>09:00</td> <td>Data Intro for Librarians</td> </tr> - <tr> <td>10:30</td> <td>Coffee</td> </tr> - <tr> <td>12:00</td> <td>Lunch break</td> </tr> - <tr> <td>13:00</td> <td>Shell Lessons for Libraries</td> </tr> - <tr> <td>14:30</td> <td>Coffee</td> </tr> - <tr> <td>16:00</td> <td>Wrap-up</td> </tr> - </table> - </div> - <div class="col-md-6"> - <h3>Day 2</h3> - <table class="table table-striped"> - <tr> <td>09:00</td> <td>Git Intro for Librarians</td> </tr> - <tr> <td>10:30</td> <td>Coffee</td> </tr> - <tr> <td>12:00</td> <td>Lunch break</td> </tr> - <tr> <td>13:00</td> <td>OpenRefine for Librarians</td> </tr> - <tr> <td>14:30</td> <td>Coffee</td> </tr> - <tr> <td>16:00</td> <td>Wrap-up</td> </tr> - </table> - </div> -</div> diff --git a/_includes/lc/syllabys.html b/_includes/lc/syllabys.html deleted file mode 100644 index 4dc2077..0000000 --- a/_includes/lc/syllabys.html +++ /dev/null @@ -1,69 +0,0 @@ -<div class="row"> - <div class="col-md-6"> - <h3 id="syllabus-python">Data Intro</h3> - <ul> - <li>Intro to data</li> - <li>Jargon busting</li> - <li>Keyboard shortcuts</li> - <li>Plain text formats</li> - <li>Naming files</li> - <li>Regular expressions</li> - <li><a href="http://data-lessons.github.io/library-data-intro/reference/">Reference...</a></li> - </ul> - </div> - <div class="col-md-6"> - <h3 id="syllabus-shell">The Unix Shell</h3> - <ul> - <li>Files and directories</li> - <li>History and tab completion</li> - <li>Counting and sorting contents in files</li> - <li>Pipes and redirection</li> - <li>Mining or searching in files</li> - <li><a href="http://data-lessons.github.io/library-shell/reference/">Reference...</a></li> - </ul> - </div> - -</div> - -<div class="row"> - <div class="col-md-6"> - <h3 id="syllabus-git">Version Control with Git</h3> - <ul> - <li>Creating a repository</li> - <li>Configuring git</li> - <li>Recording changes to files: <code>add</code>, <code>commit</code>, ...</li> - <li>Viewing state changes with <code>status</code></li> - <li>Working on the web: <code>clone</code>, <code>pull</code>, <code>push</code>, ...</li> - <li>Where to host work, and why</li> - <li><a href="http://data-lessons.github.io/library-git/reference">Reference...</a></li> - </ul> - </div> - <div class="col-md-6"> - <div class="col-md-6"> - <h3 id="syllabus-r">Open Refine</h3> - <ul> - <li>Introduction to OpenRefine</li> - <li>Importing data</li> - <li>Basic functions</li> - <li>Advanced Functions</li> - <li><a href="http://data-lessons.github.io/library-openrefine/reference">Reference...</a></li> - </ul> - </div> - </div> -</div> -<!--div class="row"> - <div class="col-md-6"> - <h3 id="syllabus-sql">SQL Intro</h3> - <ul> - <li>What is SQL?</li> - <li>Intro to SQLite Manager</li> - <li>Importing a database</li> - <li>Reading and sorting data</li> - <li>Filtering with <code>where</code></li> - <li>Combining values using aggregation</li> - <li>Combining information from multiple tables using <code>join</code></li> - <li><a href="http://data-lessons.github.io//library-sql/reference/">Reference...</a></li> - </ul> - </div> -</div> ---> diff --git a/_includes/lc/who.html b/_includes/lc/who.html deleted file mode 100644 index fd9b38c..0000000 --- a/_includes/lc/who.html +++ /dev/null @@ -1,8 +0,0 @@ -<p id="who"> - <strong>Who:</strong> - The course is for librarians, archivists, and other information workers. - <strong> - You don't need to have any previous knowledge of the tools that - will be presented at the workshop. - </strong> -</p> diff --git a/_includes/lesson_footer.html b/_includes/lesson_footer.html old mode 100644 new mode 100755 index fa5d888..beef2cb --- a/_includes/lesson_footer.html +++ b/_includes/lesson_footer.html @@ -1,37 +1,19 @@ -{% comment %} - Footer for lesson pages. -{% endcomment %} <footer> <div class="row"> <div class="col-md-6" align="left"> <h4> - Copyright © 2016–{{ 'now' | date: "%Y" }} - {% if site.carpentry == "swc" %} - <a href="{{ site.swc_site }}">Software Carpentry Foundation</a> - {% elsif site.carpentry == "dc" %} - <a href="{{ site.dc_site }}">Data Carpentry</a> - {% elsif site.carpentry == "lc" %} - <a href="{{ site.lc_site }}">Library Carpentry</a> - {% endif %} + Copyright © 2016 + {% if site.carpentry == "swc" %}<a href="{{ site.swc_site }}">Software Carpentry Foundation</a>{% endif %} + {% if site.carpentry == "dc" %}<a href="{{ site.dc_site }}">Data Carpentry</a>{% endif %} </h4> </div> <div class="col-md-6" align="right"> <h4> - {% if page.source %} - {% if page.source == "Rmd" %} - <a href="{{site.github.repository_url}}/edit/gh-pages/{{page.path|replace: "_episodes", "_episodes_rmd" | replace: ".md", ".Rmd"}}">Edit on GitHub</a> - {% endif %} - {% else %} - <a href="{{site.github.repository_url}}/edit/gh-pages/{{page.path}}">Edit on GitHub</a> - {% endif %} - / - <a href="{{ site.github.repository_url }}/blob/gh-pages/CONTRIBUTING.md">Contributing</a> - / <a href="{{ site.github.repository_url }}/">Source</a> / - <a href="{{ site.github.repository_url }}/blob/gh-pages/CITATION">Cite</a> + <a href="{{ site.github.repository_url }}/blob/gh-pages/CONTRIBUTING.md">Contributing</a> / - <a href="{{ site.contact }}">Contact</a> + <a href="mailto:{{ site.email }}">Contact</a> </h4> </div> </div> diff --git a/_includes/links.md b/_includes/links.md deleted file mode 100644 index a163786..0000000 --- a/_includes/links.md +++ /dev/null @@ -1,35 +0,0 @@ -[cc-by-human]: https://creativecommons.org/licenses/by/4.0/ -[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode -[concept-maps]: http://swcarpentry.github.io/instructor-training/08-memory/ -[contact]: mailto:lessons@software-carpentry.org -[contrib-covenant]: http://contributor-covenant.org/ -[contributing]: {{ site.github.repository_url }}/blob/gh-pages/CONTRIBUTING.md -[cran-checkpoint]: https://cran.r-project.org/web/packages/checkpoint/index.html -[cran-knitr]: https://cran.r-project.org/web/packages/knitr/index.html -[cran-stringr]: https://cran.r-project.org/web/packages/stringr/index.html -[github-importer]: https://import.github.com/ -[importer]: http://import.github.com/new -[jekyll-collection]: https://jekyllrb.com/docs/collections/ -[jekyll-install]: https://jekyllrb.com/docs/installation/ -[jekyll-windows]: http://jekyll-windows.juthilo.com/ -[jekyll]: https://jekyllrb.com/ -[jupyter]: https://jupyter.org/ -[mit-license]: http://opensource.org/licenses/mit-license.html -[morea]: https://morea-framework.github.io/ -[numfocus]: http://numfocus.org/ -[osi]: http://opensource.org -[pandoc]: https://pandoc.org/ -[paper-now]: https://github.com/PeerJ/paper-now -[python-gapminder]: https://swcarpentry.github.io/python-novice-gapminder/ -[pyyaml]: https://pypi.python.org/pypi/PyYAML -[r-markdown]: http://rmarkdown.rstudio.com/ -[rstudio]: https://www.rstudio.com/ -[ruby-install-guide]: https://www.ruby-lang.org/en/downloads/ -[ruby-installer]: http://rubyinstaller.org/ -[rubygems]: https://rubygems.org/pages/download/ -[styles]: https://github.com/swcarpentry/styles/ -[training]: http://swcarpentry.github.io/instructor-training/ -[workshop-repo]: {{ site.workshop_repo }} -[yaml]: http://yaml.org/ -[coc]: https://software-carpentry.org/conduct/ -[coc-reporting]: https://software-carpentry.org/CoC-reporting/ \ No newline at end of file diff --git a/_includes/main_title.html b/_includes/main_title.html old mode 100644 new mode 100755 index 8e22ced..60b8b06 --- a/_includes/main_title.html +++ b/_includes/main_title.html @@ -1,4 +1 @@ -{% comment %} - Main title for lesson pages. -{% endcomment %} <h1 class="maintitle"><a href="{{ page.root }}/">{{ site.title }}</a>{% if page.title %}: {{ page.title }}{% endif %}</h1> diff --git a/_includes/navbar.html b/_includes/navbar.html old mode 100644 new mode 100755 index 7782c9d..b0a2c3d --- a/_includes/navbar.html +++ b/_includes/navbar.html @@ -1,6 +1,3 @@ -{% comment %} - Lesson navigation bar. -{% endcomment %} <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> @@ -20,9 +17,13 @@ <a href="{{ site.dc_site }}" class="pull-left"> <img class="navbar-logo" src="{{ page.root }}/assets/img/dc-icon-black.svg" alt="Data Carpentry logo" /> </a> - {% elsif page.carpentry == "lc" %} - <a href="{{ site.lc_site }}" class="pull-left"> - <img class="navbar-logo" src="{{ page.root }}/assets/img/lc-icon-black.png" alt="Library Carpentry logo" /> + {% elsif site.carpentry == "swc" %} + <a href="{{ site.swc_site }}" class="pull-left"> + <img class="navbar-logo" src="{{ page.root }}/assets/img/swc-icon-blue.svg" alt="Software Carpentry logo" /> + </a> + {% elsif site.carpentry == "dc" %} + <a href="{{ site.dc_site }}" class="pull-left"> + <img class="navbar-logo" src="{{ page.root }}/assets/img/dc-icon-black.svg" alt="Data Carpentry logo" /> </a> {% endif %} @@ -39,14 +40,13 @@ {% comment %} Show setup instructions, reference guide, and lesson episodes for lessons. {% endcomment %} {% if site.kind == "lesson" %} <li><a href="{{ page.root }}/setup/">Setup</a></li> + <li><a href="{{ page.root }}/reference/">Reference</a></li> <li class="dropdown"> <a href="{{ page.root }}/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Episodes <span class="caret"></span></a> <ul class="dropdown-menu"> {% for episode in site.episodes %} <li><a href="{{ page.root }}{{ episode.url }}">{{ episode.title }}</a></li> {% endfor %} - <li role="separator" class="divider"></li> - <li><a href="{{ page.root }}/aio/">All in one page (Beta)</a></li> </ul> </li> {% endif %} @@ -56,7 +56,6 @@ <li class="dropdown"> <a href="{{ page.root }}/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Extras <span class="caret"></span></a> <ul class="dropdown-menu"> - <li><a href="{{ page.root }}/reference/">Reference</a></li> {% for extra in site.extras %} <li><a href="{{ page.root }}{{ extra.url }}">{{ extra.title }}</a></li> {% endfor %} @@ -66,13 +65,6 @@ {% comment %} Always show license. {% endcomment %} <li><a href="{{ page.root }}/license/">License</a></li> - {% if page.source %} - {% if page.source == "Rmd" %} - <li><a href="{{site.github.repository_url}}/edit/gh-pages/{{page.path|replace: "_episodes", "_episodes_rmd" | replace: ".md", ".Rmd"}}">Improve this page <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a></li> - {% endif %} - {% else %} - <li><a href="{{site.github.repository_url}}/edit/gh-pages/{{page.path}}">Improve this page <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a></li> - {% endif %} </ul> <form class="navbar-form navbar-right" role="search" id="search" onsubmit="google_search(); return false;"> <div class="form-group"> diff --git a/_includes/sc/intro.html b/_includes/sc/intro.html deleted file mode 100644 index 7b9fbf5..0000000 --- a/_includes/sc/intro.html +++ /dev/null @@ -1,18 +0,0 @@ -<p> - <a href="{{site.swc_site}}">Software Carpentry</a> - aims to help researchers get their work done - in less time and with less pain - by teaching them basic research computing skills. - This hands-on workshop will cover basic concepts and tools, - including program design, version control, data management, - and task automation. - Participants will be encouraged to help one another - and to apply what they have learned to their own research problems. -</p> -<p align="center"> - <em> - For more information on what we teach and why, - please see our paper - "<a href="http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1001745">Best Practices for Scientific Computing</a>". - </em> -</p> diff --git a/_includes/sc/schedule.html b/_includes/sc/schedule.html deleted file mode 100644 index 6894a19..0000000 --- a/_includes/sc/schedule.html +++ /dev/null @@ -1,24 +0,0 @@ -<div class="row"> - <div class="col-md-6"> - <h3>Day 1</h3> - <table class="table table-striped"> - <tr> <td>09:00</td> <td>Automating tasks with the Unix shell</td> </tr> - <tr> <td>10:30</td> <td>Coffee</td> </tr> - <tr> <td>12:00</td> <td>Lunch break</td> </tr> - <tr> <td>13:00</td> <td>Building programs with Python</td> </tr> - <tr> <td>14:30</td> <td>Coffee</td> </tr> - <tr> <td>16:00</td> <td>Wrap-up</td> </tr> - </table> - </div> - <div class="col-md-6"> - <h3>Day 2</h3> - <table class="table table-striped"> - <tr> <td>09:00</td> <td>Version control with Git</td> </tr> - <tr> <td>10:30</td> <td>Coffee</td> </tr> - <tr> <td>12:00</td> <td>Lunch break</td> </tr> - <tr> <td>13:00</td> <td>Managing data with SQL</td> </tr> - <tr> <td>14:30</td> <td>Coffee</td> </tr> - <tr> <td>16:00</td> <td>Wrap-up</td> </tr> - </table> - </div> -</div> diff --git a/_includes/sc/syllabus.html b/_includes/sc/syllabus.html deleted file mode 100644 index a325cee..0000000 --- a/_includes/sc/syllabus.html +++ /dev/null @@ -1,96 +0,0 @@ -<div class="row"> - <div class="col-md-6"> - <h3 id="syllabus-shell">The Unix Shell</h3> - <ul> - <li>Files and directories</li> - <li>History and tab completion</li> - <li>Pipes and redirection</li> - <li>Looping over files</li> - <li>Creating and running shell scripts</li> - <li>Finding things</li> - <li><a href="{{site.swc_pages}}/shell-novice/reference/">Reference...</a></li> - </ul> - </div> - <div class="col-md-6"> - <h3 id="syllabus-python">Programming in Python</h3> - <ul> - <li>Using libraries</li> - <li>Working with arrays</li> - <li>Reading and plotting data</li> - <li>Creating and using functions</li> - <li>Loops and conditionals</li> - <li>Defensive programming</li> - <li>Using Python from the command line</li> - <li><a href="{{site.swc_pages}}/python-novice-inflammation/reference/">Reference...</a></li> - </ul> - </div> - <!-- - <div class="col-md-6"> - <h3 id="syllabus-r">Programming in R</h3> - <ul> - <li>Working with vectors and data frames</li> - <li>Reading and plotting data</li> - <li>Creating and using functions</li> - <li>Loops and conditionals</li> - <li>Using R from the command line</li> - <li><a href="{{site.swc_pages}}/r-novice-inflammation/reference/">Reference...</a></li> - </ul> - </div> - --> - <!-- - <div class="col-md-6"> - <h3 id="syllabus-matlab">Programming in MATLAB</h3> - <ul> - <li>Working with arrays</li> - <li>Reading and plotting data</li> - <li>Creating and using functions</li> - <li>Loops and conditionals</li> - <li>Defensive programming</li> - <li><a href="{{site.swc_pages}}/matlab-novice-inflammation/reference/">Reference...</a></li> - </ul> - </div> - --> -</div> - -<div class="row"> - <div class="col-md-6"> - <h3 id="syllabus-git">Version Control with Git</h3> - <ul> - <li>Creating a repository</li> - <li>Recording changes to files: <code>add</code>, <code>commit</code>, ...</li> - <li>Viewing changes: <code>status</code>, <code>diff</code>, ...</li> - <li>Ignoring files</li> - <li>Working on the web: <code>clone</code>, <code>pull</code>, <code>push</code>, ...</li> - <li>Resolving conflicts</li> - <li>Open licenses</li> - <li>Where to host work, and why</li> - <li><a href="{{site.swc_pages}}/git-novice/reference/">Reference...</a></li> - </ul> - </div> - <!-- - <div class="col-md-6"> - <h3 id="syllabus-sql">Managing Data with SQL</h3> - <ul> - <li>Reading and sorting data</li> - <li>Filtering with <code>where</code></li> - <li>Calculating new values on the fly</li> - <li>Handling missing values</li> - <li>Combining values using aggregation</li> - <li>Combining information from multiple tables using <code>join</code></li> - <li>Creating, modifying, and deleting data</li> - <li>Programming with databases</li> - <li><a href="{{site.swc_pages}}/sql-novice-survey/reference/">Reference...</a></li> - </ul> - </div> - --> - <div class="col-md-6"> - <h3 id="syllabus-r">Open Refine</h3> - <ul> - <li>Introduction to OpenRefine</li> - <li>Importing data</li> - <li>Basic functions</li> - <li>Advanced Functions</li> - <li><a href="{{site.lc_pages}}library-openrefine/reference">Reference...</a></li> - </ul> - </div> -</div> diff --git a/_includes/sc/who.html b/_includes/sc/who.html deleted file mode 100644 index 2d8e94a..0000000 --- a/_includes/sc/who.html +++ /dev/null @@ -1,8 +0,0 @@ -<p id="who"> - <strong>Who:</strong> - The course is aimed at graduate students and other researchers. - <strong> - You don't need to have any previous knowledge of the tools - that will be presented at the workshop. - </strong> -</p> diff --git a/_includes/syllabus.html b/_includes/syllabus.html old mode 100644 new mode 100755 index 95ec2e1..bd520ed --- a/_includes/syllabus.html +++ b/_includes/syllabus.html @@ -5,7 +5,6 @@ <div class="syllabus"> <h2 id="schedule">Schedule</h2> - {% assign lesson_number = 0 %} {% assign day = 0 %} {% assign multiday = false %} {% for episode in site.episodes %} @@ -14,12 +13,6 @@ <h2 id="schedule">Schedule</h2> {% assign current = site.start_time %} <table class="table table-striped"> - <tr> - {% if multiday %}<td class="col-md-1"></td>{% endif %} - <td class="{% if multiday %}col-md-1{% else %}col-md-2{% endif %}"></td> - <td class="col-md-3"><a href="{{ page.root }}/setup">Setup</a></td> - <td class="col-md-7">Download files required for the lesson</td> - </tr> {% for episode in site.episodes %} {% if episode.start %} {% comment %} Starting a new day? {% endcomment %} {% assign day = day | plus: 1 %} @@ -27,8 +20,8 @@ <h2 id="schedule">Schedule</h2> {% assign hours = current | divided_by: 60 %} {% assign minutes = current | modulo: 60 %} <tr> - {% if multiday %}<td class="col-md-1"></td>{% endif %} - <td class="{% if multiday %}col-md-1{% else %}col-md-2{% endif %}">{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }}</td> + {% if multiday %}<td></td>{% endif %} + <td class="col-md-1">{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }}</td> <td class="col-md-3">Finish</td> <td class="col-md-7"></td> </tr> @@ -39,10 +32,9 @@ <h2 id="schedule">Schedule</h2> {% assign minutes = current | modulo: 60 %} <tr> {% if multiday %}<td class="col-md-1">{% if episode.start %}Day {{ day }}{% endif %}</td>{% endif %} - <td class="{% if multiday %}col-md-1{% else %}col-md-2{% endif %}">{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }}</td> + <td class="col-md-1">{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }}</td> <td class="col-md-3"> - {% assign lesson_number = lesson_number | plus: 1 %} - {{ lesson_number }}. <a href="{{ page.root }}{{ episode.url }}">{{ episode.title }}</a> + <a href="{{ page.root }}{{ episode.url }}">{{ episode.title }}</a> </td> <td class="col-md-7"> {% if episode.break %} @@ -64,8 +56,8 @@ <h2 id="schedule">Schedule</h2> {% assign hours = current | divided_by: 60 %} {% assign minutes = current | modulo: 60 %} <tr> - {% if multiday %}<td class="col-md-1"></td>{% endif %} - <td class="{% if multiday %}col-md-1{% else %}col-md-2{% endif %}">{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }}</td> + {% if multiday %}<td></td>{% endif %} + <td class="col-md-1">{% if hours < 10 %}0{% endif %}{{ hours }}:{% if minutes < 10 %}0{% endif %}{{ minutes }}</td> <td class="col-md-3">Finish</td> <td class="col-md-7"></td> </tr> diff --git a/_includes/workshop_ad.html b/_includes/workshop_ad.html old mode 100644 new mode 100755 index e8e72e3..bffe9b9 --- a/_includes/workshop_ad.html +++ b/_includes/workshop_ad.html @@ -1,6 +1,3 @@ -{% comment %} - Advertising box at the top of a workshop website home page. -{% endcomment %} <div class="jumbotron"> <div class="row"> <div class="col-md-10 col-md-offset-1"> diff --git a/_includes/workshop_footer.html b/_includes/workshop_footer.html old mode 100644 new mode 100755 index 897e421..31e5f37 --- a/_includes/workshop_footer.html +++ b/_includes/workshop_footer.html @@ -1,24 +1,10 @@ -{% comment %} - Footer for a standard workshop. -{% endcomment %} <footer> <div class="row"> <div class="col-md-6" align="left"> - <h4> - Copyright © 2016 - {% if site.carpentry == "swc" %} - <a href="{{ site.swc_site }}">Software Carpentry Foundation</a> - {% elsif site.carpentry == "dc" %} - <a href="{{ site.dc_site }}">Data Carpentry</a> - {% elsif site.carpentry == "lc" %} - <a href="{{ site.lc_site }}">Library Carpentry</a> - {% endif %} - </h4> + <h4><a href="{{ site.swc_site }}">Software Carpentry</a></h4> </div> <div class="col-md-6" align="right"> - <h4> - <a href="mailto:{{ site.email }}">Contact</a> - </h4> + <h4><a href="{{ site.dc_site }}">Data Carpentry</a></h4> </div> </div> </footer> diff --git a/_layouts/base.html b/_layouts/base.html old mode 100644 new mode 100755 index 365d2e5..06f316d --- a/_layouts/base.html +++ b/_layouts/base.html @@ -14,10 +14,9 @@ <link rel="stylesheet" type="text/css" href="{{ page.root }}/assets/css/lesson.css" /> {% if site.carpentry == "swc" %} <link rel="shortcut icon" type="image/x-icon" href="/favicon-swc.ico" /> - {% elsif site.carpentry == "dc" %} + {% endif %} + {% if site.carpentry == "dc" %} <link rel="shortcut icon" type="image/x-icon" href="/favicon-dc.ico" /> - {% elsif site.carpentry == "lc" %} - <link rel="shortcut icon" type="image/x-icon" href="/favicon-lc.ico" /> {% endif %} <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> diff --git a/_layouts/break.html b/_layouts/break.html old mode 100644 new mode 100755 index ac58232..6e2a6a0 --- a/_layouts/break.html +++ b/_layouts/break.html @@ -2,9 +2,6 @@ layout: base --- {% include episode_navbar.html episode_navbar_title=true %} -<article> -{% include episode_title.html %} {% include episode_break.html %} {{content}} -</article> {% include episode_navbar.html episode_navbar_title=false %} diff --git a/_layouts/episode.html b/_layouts/episode.html old mode 100644 new mode 100755 index 0b276e7..d774a68 --- a/_layouts/episode.html +++ b/_layouts/episode.html @@ -2,10 +2,7 @@ layout: base --- {% include episode_navbar.html episode_navbar_title=true %} -<article> -{% include episode_title.html %} {% include episode_overview.html %} {{content}} {% include episode_keypoints.html %} -</article> {% include episode_navbar.html episode_navbar_title=false %} diff --git a/_layouts/lesson.html b/_layouts/lesson.html old mode 100644 new mode 100755 diff --git a/_layouts/page.html b/_layouts/page.html old mode 100644 new mode 100755 diff --git a/_layouts/reference.html b/_layouts/reference.html old mode 100644 new mode 100755 diff --git a/_layouts/workshop.html b/_layouts/workshop.html old mode 100644 new mode 100755 index 2f4cd30..f29e3ce --- a/_layouts/workshop.html +++ b/_layouts/workshop.html @@ -30,10 +30,9 @@ <link rel="stylesheet" type="text/css" href="{{ page.root }}/assets/css/lesson.css" /> {% if site.carpentry == "swc" %} <link rel="shortcut icon" type="image/x-icon" href="/favicon-swc.ico" /> - {% elsif site.carpentry == "dc" %} + {% endif %} + {% if site.carpentry == "dc" %} <link rel="shortcut icon" type="image/x-icon" href="/favicon-dc.ico" /> - {% elsif site.carpentry == "lc" %} - <link rel="shortcut icon" type="image/x-icon" href="/favicon-lc.ico" /> {% endif %} <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> diff --git a/assets/css/bootstrap-theme.css b/assets/css/bootstrap-theme.css old mode 100644 new mode 100755 diff --git a/assets/css/bootstrap-theme.css.map b/assets/css/bootstrap-theme.css.map old mode 100644 new mode 100755 diff --git a/assets/css/bootstrap.css b/assets/css/bootstrap.css old mode 100644 new mode 100755 index 0fe7cd5..46ba03e --- a/assets/css/bootstrap.css +++ b/assets/css/bootstrap.css @@ -2263,7 +2263,7 @@ th { text-align: left; } .table { - width: 100%; + /* width: 100%; -- CHANGE -- */ max-width: 100%; margin-bottom: 20px; } diff --git a/assets/css/bootstrap.css.map b/assets/css/bootstrap.css.map old mode 100644 new mode 100755 diff --git a/assets/css/lesson.scss b/assets/css/lesson.scss old mode 100644 new mode 100755 index fe008e5..752d7c9 --- a/assets/css/lesson.scss +++ b/assets/css/lesson.scss @@ -32,7 +32,6 @@ $color-testimonial: #fc8dc1 !default; color: $color; border-left: solid 5px $color; margin-bottom: 0px; - border-radius: 4px 0 0 4px; } .error { @include cdSetup($color-error); } @@ -46,18 +45,6 @@ $color-testimonial: #fc8dc1 !default; .r { @include cdSetup($color-source); } .sql { @include cdSetup($color-source); } -.error pre, -.output pre, -.source pre, -.bash pre, -.make pre, -.matlab pre, -.python pre, -.r pre, -.sql pre { - border-radius: 0 4px 4px 0; -} - //---------------------------------------- // Specialized blockquote environments for learning objectives, callouts, etc. //---------------------------------------- @@ -113,9 +100,9 @@ $codeblock-padding: 5px !default; //---------------------------------------- code { - padding: 2px 5px; - color: #3d90d9; - background-color: #e7e7e7; + padding: 0 0; + color: inherit; + background-color: inherit; } img { @@ -146,7 +133,7 @@ div.branding { ul, ol { - padding-left: 2em; + padding-left: 1em; } span.fold-unfold { diff --git a/assets/fonts/glyphicons-halflings-regular.eot b/assets/fonts/glyphicons-halflings-regular.eot old mode 100644 new mode 100755 diff --git a/assets/fonts/glyphicons-halflings-regular.svg b/assets/fonts/glyphicons-halflings-regular.svg old mode 100644 new mode 100755 diff --git a/assets/fonts/glyphicons-halflings-regular.ttf b/assets/fonts/glyphicons-halflings-regular.ttf old mode 100644 new mode 100755 diff --git a/assets/fonts/glyphicons-halflings-regular.woff b/assets/fonts/glyphicons-halflings-regular.woff old mode 100644 new mode 100755 diff --git a/assets/fonts/glyphicons-halflings-regular.woff2 b/assets/fonts/glyphicons-halflings-regular.woff2 old mode 100644 new mode 100755 diff --git a/assets/img/dc-icon-black.svg b/assets/img/dc-icon-black.svg old mode 100644 new mode 100755 diff --git a/assets/img/lc-icon-black.png b/assets/img/lc-icon-black.png deleted file mode 100644 index e49c6d5..0000000 Binary files a/assets/img/lc-icon-black.png and /dev/null differ diff --git a/assets/img/lc-icon-black.svg b/assets/img/lc-icon-black.svg deleted file mode 100644 index df71189..0000000 --- a/assets/img/lc-icon-black.svg +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" - "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> -<svg version="1.0" xmlns="http://www.w3.org/2000/svg" - width="600.000000pt" height="200.000000pt" viewBox="0 0 600.000000 200.000000" - preserveAspectRatio="xMidYMid meet"> - -<g transform="translate(0.000000,200.000000) scale(0.100000,-0.100000)" -fill="#000000" stroke="none"> -<path d="M1005 1355 l0 -325 248 0 247 0 0 83 0 82 -152 0 -153 0 0 243 0 242 --95 0 -95 0 0 -325z"/> -<path d="M1545 1355 l0 -325 98 0 97 0 0 325 0 325 -97 0 -98 0 0 -325z"/> -<path d="M1835 1356 l0 -326 190 0 c105 0 208 5 229 10 81 18 128 74 133 157 -5 75 -18 120 -75 148 -23 11 -41 22 -42 25 0 3 14 11 31 19 35 15 68 77 69 -126 0 51 -40 116 -85 139 -36 19 -61 21 -245 24 l-205 3 0 -325z m326 164 c22 --12 26 -59 7 -78 -7 -7 -40 -12 -80 -12 l-68 0 0 50 0 50 61 0 c33 0 69 -5 80 --10z m9 -233 c17 -9 26 -22 28 -44 5 -46 -26 -63 -110 -63 l-68 0 0 60 0 60 -63 0 c34 0 73 -6 87 -13z"/> -<path d="M2465 1355 l0 -325 96 0 95 0 -4 115 -5 115 47 0 c64 0 85 -24 122 --137 l29 -93 103 0 c56 0 102 3 102 8 0 8 -82 202 -102 240 -7 13 -23 29 -36 -36 l-24 13 35 22 c45 27 68 78 68 146 0 91 -37 145 -120 173 -21 8 -106 12 --220 12 l-186 0 0 -325z m309 165 c21 -8 26 -16 26 -43 0 -47 -15 -57 -87 -57 -l-63 0 0 55 0 55 49 0 c27 0 61 -4 75 -10z"/> -<path d="M3290 1665 c0 -8 -47 -151 -105 -319 -58 -167 -105 -307 -105 -310 0 --3 46 -6 103 -6 l103 0 14 68 15 67 100 0 100 0 15 -67 14 -68 103 0 c57 0 -103 3 103 7 0 3 -47 143 -105 310 -58 167 -105 310 -105 318 0 12 -22 15 -125 -15 -103 0 -125 -3 -125 -15z m174 -317 l6 -28 -55 0 c-30 0 -55 1 -55 3 0 2 6 -26 14 53 8 27 20 69 27 94 l12 45 22 -70 c12 -38 25 -82 29 -97z"/> -<path d="M3805 1355 l0 -325 96 0 95 0 -4 115 -5 115 47 0 c64 0 85 -24 122 --137 l29 -93 103 0 c56 0 102 3 102 8 0 8 -82 202 -102 240 -7 13 -23 29 -36 -36 l-24 13 35 22 c45 27 68 78 68 146 0 91 -37 145 -120 173 -21 8 -106 12 --220 12 l-186 0 0 -325z m309 165 c21 -8 26 -16 26 -43 0 -47 -15 -57 -87 -57 -l-63 0 0 55 0 55 49 0 c27 0 61 -4 75 -10z"/> -<path d="M4380 1674 c0 -3 13 -24 28 -47 16 -23 68 -108 115 -189 l87 -146 0 --131 0 -131 95 0 95 0 0 130 0 130 115 192 c63 105 115 193 115 195 0 1 -49 3 --109 3 l-108 0 -53 -107 -52 -108 -52 107 -51 107 -112 0 c-62 1 -113 -2 -113 --5z"/> -<path d="M357 999 c-160 -38 -254 -197 -228 -386 18 -121 73 -203 169 -250 50 --25 68 -28 152 -28 84 0 102 3 152 28 59 29 96 68 122 131 26 62 22 73 -29 80 --148 20 -132 22 -148 -15 -18 -45 -38 -60 -85 -66 -88 -12 -142 56 -142 177 0 -39 6 85 14 104 39 94 169 104 206 16 14 -35 12 -34 113 -15 43 8 80 15 82 15 -6 0 -12 55 -28 87 -24 46 -95 102 -151 118 -54 16 -140 18 -199 4z"/> -<path d="M2995 1003 l-230 -3 0 -325 0 -325 253 0 252 0 0 80 0 79 -157 3 --158 3 -3 48 -3 48 138 -2 138 -2 0 78 0 79 -138 -3 -138 -3 3 44 3 43 153 0 -152 0 0 83 c0 72 -2 82 -17 80 -10 -2 -121 -4 -248 -5z"/> -<path d="M4000 923 l0 -83 100 0 100 0 0 -245 0 -245 98 0 97 0 -3 245 -4 245 -106 0 106 0 0 83 0 82 -300 0 -300 0 0 -82z"/> -<path d="M990 985 c0 -8 -47 -151 -105 -319 -58 -167 -105 -307 -105 -310 0 --3 46 -6 103 -6 l103 0 14 68 15 67 100 0 100 0 15 -67 14 -68 103 0 c57 0 -103 3 103 7 0 3 -47 143 -105 310 -58 167 -105 310 -105 318 0 12 -22 15 -125 -15 -103 0 -125 -3 -125 -15z m174 -317 l6 -28 -55 0 c-30 0 -55 1 -55 3 0 2 6 -26 14 53 8 27 20 69 27 94 l12 45 22 -70 c12 -38 25 -82 29 -97z"/> -<path d="M1505 675 l0 -325 96 0 95 0 -4 115 -5 115 47 0 c64 0 85 -24 122 --137 l29 -93 103 0 c56 0 102 3 102 8 0 8 -82 202 -102 240 -7 13 -23 29 -36 -36 l-24 13 35 22 c45 27 68 78 68 146 0 91 -37 145 -120 173 -21 8 -106 12 --220 12 l-186 0 0 -325z m309 165 c21 -8 26 -16 26 -43 0 -47 -15 -57 -87 -57 -l-63 0 0 55 0 55 49 0 c27 0 61 -4 75 -10z"/> -<path d="M2155 675 l0 -325 97 0 97 0 -6 98 -6 99 89 6 c100 7 145 19 190 53 -97 72 100 276 4 344 -57 41 -111 50 -294 50 l-171 0 0 -325z m320 159 c25 -10 -36 -49 24 -81 -14 -38 -25 -43 -96 -43 l-63 0 0 65 0 65 59 0 c33 0 67 -3 76 --6z"/> -<path d="M3345 675 l0 -325 95 0 95 0 -3 177 -3 178 24 -40 c13 -22 50 -80 83 --130 34 -49 73 -111 88 -137 l28 -48 96 0 97 0 0 325 0 325 -95 0 -95 0 3 --177 4 -178 -111 169 c-61 93 -111 173 -111 178 0 4 -44 8 -97 8 l-98 0 0 --325z"/> -<path d="M4655 675 l0 -325 96 0 95 0 -4 115 -5 115 47 0 c64 0 85 -24 122 --137 l29 -93 103 0 c56 0 102 3 102 8 0 8 -82 202 -102 240 -7 13 -23 29 -36 -36 l-24 13 35 22 c45 27 68 78 68 146 0 91 -37 145 -120 173 -21 8 -106 12 --220 12 l-186 0 0 -325z m309 165 c21 -8 26 -16 26 -43 0 -47 -15 -57 -87 -57 -l-63 0 0 55 0 55 49 0 c27 0 61 -4 75 -10z"/> -<path d="M5230 994 c0 -3 13 -24 28 -47 16 -23 68 -108 115 -189 l87 -146 0 --131 0 -131 95 0 95 0 0 130 0 130 115 192 c63 105 115 193 115 195 0 1 -49 3 --109 3 l-108 0 -53 -107 -52 -108 -52 107 -51 107 -112 0 c-62 1 -113 -2 -113 --5z"/> -</g> -</svg> diff --git a/assets/img/swc-icon-blue.svg b/assets/img/swc-icon-blue.svg old mode 100644 new mode 100755 diff --git a/assets/img/swc-logo-blue.png b/assets/img/swc-logo-blue.png old mode 100644 new mode 100755 diff --git a/assets/img/swc-logo-blue.svg b/assets/img/swc-logo-blue.svg old mode 100644 new mode 100755 diff --git a/assets/img/swc-logo-white.png b/assets/img/swc-logo-white.png old mode 100644 new mode 100755 diff --git a/assets/img/swc-logo-white.svg b/assets/img/swc-logo-white.svg old mode 100644 new mode 100755 diff --git a/assets/js/bootstrap.min.js b/assets/js/bootstrap.min.js old mode 100644 new mode 100755 diff --git a/assets/js/jquery.min.js b/assets/js/jquery.min.js old mode 100644 new mode 100755 diff --git a/assets/js/jquery.min.map b/assets/js/jquery.min.map deleted file mode 100644 index 01f1f98..0000000 --- a/assets/js/jquery.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"jquery-1.11.3.min.js","sources":["jquery-1.11.3.js"],"names":["global","factory","module","exports","document","w","Error","window","this","noGlobal","deletedIds","slice","concat","push","indexOf","class2type","toString","hasOwn","hasOwnProperty","support","version","jQuery","selector","context","fn","init","rtrim","rmsPrefix","rdashAlpha","fcamelCase","all","letter","toUpperCase","prototype","jquery","constructor","length","toArray","call","get","num","pushStack","elems","ret","merge","prevObject","each","callback","args","map","elem","i","apply","arguments","first","eq","last","len","j","end","sort","splice","extend","src","copyIsArray","copy","name","options","clone","target","deep","isFunction","isPlainObject","isArray","undefined","expando","Math","random","replace","isReady","error","msg","noop","obj","type","Array","isWindow","isNumeric","parseFloat","isEmptyObject","key","nodeType","e","ownLast","globalEval","data","trim","execScript","camelCase","string","nodeName","toLowerCase","value","isArraylike","text","makeArray","arr","results","Object","inArray","max","second","grep","invert","callbackInverse","matches","callbackExpect","arg","guid","proxy","tmp","now","Date","split","Sizzle","Expr","getText","isXML","tokenize","compile","select","outermostContext","sortInput","hasDuplicate","setDocument","docElem","documentIsHTML","rbuggyQSA","rbuggyMatches","contains","preferredDoc","dirruns","done","classCache","createCache","tokenCache","compilerCache","sortOrder","a","b","MAX_NEGATIVE","pop","push_native","list","booleans","whitespace","characterEncoding","identifier","attributes","pseudos","rwhitespace","RegExp","rcomma","rcombinators","rattributeQuotes","rpseudo","ridentifier","matchExpr","ID","CLASS","TAG","ATTR","PSEUDO","CHILD","bool","needsContext","rinputs","rheader","rnative","rquickExpr","rsibling","rescape","runescape","funescape","_","escaped","escapedWhitespace","high","String","fromCharCode","unloadHandler","childNodes","els","seed","match","m","groups","old","nid","newContext","newSelector","ownerDocument","exec","getElementById","parentNode","id","getElementsByTagName","getElementsByClassName","qsa","test","getAttribute","setAttribute","toSelector","testContext","join","querySelectorAll","qsaError","removeAttribute","keys","cache","cacheLength","shift","markFunction","assert","div","createElement","removeChild","addHandle","attrs","handler","attrHandle","siblingCheck","cur","diff","sourceIndex","nextSibling","createInputPseudo","createButtonPseudo","createPositionalPseudo","argument","matchIndexes","documentElement","node","hasCompare","parent","doc","defaultView","top","addEventListener","attachEvent","className","appendChild","createComment","getById","getElementsByName","find","filter","attrId","getAttributeNode","tag","innerHTML","input","matchesSelector","webkitMatchesSelector","mozMatchesSelector","oMatchesSelector","msMatchesSelector","disconnectedMatch","compareDocumentPosition","adown","bup","compare","sortDetached","aup","ap","bp","unshift","expr","elements","attr","val","specified","uniqueSort","duplicates","detectDuplicates","sortStable","textContent","firstChild","nodeValue","selectors","createPseudo","relative",">","dir"," ","+","~","preFilter","excess","unquoted","nodeNameSelector","pattern","operator","check","result","what","simple","forward","ofType","xml","outerCache","nodeIndex","start","useCache","lastChild","pseudo","setFilters","idx","matched","not","matcher","unmatched","has","innerText","lang","elemLang","hash","location","root","focus","activeElement","hasFocus","href","tabIndex","enabled","disabled","checked","selected","selectedIndex","empty","header","button","even","odd","lt","gt","radio","checkbox","file","password","image","submit","reset","filters","parseOnly","tokens","soFar","preFilters","cached","addCombinator","combinator","base","checkNonElements","doneName","oldCache","newCache","elementMatcher","matchers","multipleContexts","contexts","condense","newUnmatched","mapped","setMatcher","postFilter","postFinder","postSelector","temp","preMap","postMap","preexisting","matcherIn","matcherOut","matcherFromTokens","checkContext","leadingRelative","implicitRelative","matchContext","matchAnyContext","matcherFromGroupMatchers","elementMatchers","setMatchers","bySet","byElement","superMatcher","outermost","matchedCount","setMatched","contextBackup","dirrunsUnique","token","compiled","div1","defaultValue","unique","isXMLDoc","rneedsContext","rsingleTag","risSimple","winnow","qualifier","self","is","rootjQuery","charAt","parseHTML","ready","rparentsprev","guaranteedUnique","children","contents","next","prev","until","sibling","n","r","targets","closest","l","pos","index","prevAll","add","addBack","parents","parentsUntil","nextAll","nextUntil","prevUntil","siblings","contentDocument","contentWindow","reverse","rnotwhite","optionsCache","createOptions","object","flag","Callbacks","firing","memory","fired","firingLength","firingIndex","firingStart","stack","once","fire","stopOnFalse","disable","remove","lock","locked","fireWith","Deferred","func","tuples","state","promise","always","deferred","fail","then","fns","newDefer","tuple","returned","resolve","reject","progress","notify","pipe","stateString","when","subordinate","resolveValues","remaining","updateFunc","values","progressValues","notifyWith","resolveWith","progressContexts","resolveContexts","readyList","readyWait","holdReady","hold","wait","body","setTimeout","triggerHandler","off","detach","removeEventListener","completed","detachEvent","event","readyState","frameElement","doScroll","doScrollCheck","strundefined","inlineBlockNeedsLayout","container","style","cssText","zoom","offsetWidth","deleteExpando","acceptData","noData","rbrace","rmultiDash","dataAttr","parseJSON","isEmptyDataObject","internalData","pvt","thisCache","internalKey","isNode","toJSON","internalRemoveData","cleanData","applet ","embed ","object ","hasData","removeData","_data","_removeData","queue","dequeue","startLength","hooks","_queueHooks","stop","setter","clearQueue","count","defer","pnum","source","cssExpand","isHidden","el","css","access","chainable","emptyGet","raw","bulk","rcheckableType","fragment","createDocumentFragment","leadingWhitespace","tbody","htmlSerialize","html5Clone","cloneNode","outerHTML","appendChecked","noCloneChecked","checkClone","noCloneEvent","click","eventName","change","focusin","rformElems","rkeyEvent","rmouseEvent","rfocusMorph","rtypenamespace","returnTrue","returnFalse","safeActiveElement","err","types","events","t","handleObjIn","special","eventHandle","handleObj","handlers","namespaces","origType","elemData","handle","triggered","dispatch","delegateType","bindType","namespace","delegateCount","setup","mappedTypes","origCount","teardown","removeEvent","trigger","onlyHandlers","ontype","bubbleType","eventPath","Event","isTrigger","namespace_re","noBubble","parentWindow","isPropagationStopped","preventDefault","isDefaultPrevented","_default","fix","handlerQueue","delegateTarget","preDispatch","currentTarget","isImmediatePropagationStopped","stopPropagation","postDispatch","sel","prop","originalEvent","fixHook","fixHooks","mouseHooks","keyHooks","props","srcElement","metaKey","original","which","charCode","keyCode","eventDoc","fromElement","pageX","clientX","scrollLeft","clientLeft","pageY","clientY","scrollTop","clientTop","relatedTarget","toElement","load","blur","beforeunload","returnValue","simulate","bubble","isSimulated","defaultPrevented","timeStamp","cancelBubble","stopImmediatePropagation","mouseenter","mouseleave","pointerenter","pointerleave","orig","related","submitBubbles","form","_submit_bubble","changeBubbles","propertyName","_just_changed","focusinBubbles","attaches","on","one","origFn","createSafeFragment","nodeNames","safeFrag","rinlinejQuery","rnoshimcache","rleadingWhitespace","rxhtmlTag","rtagName","rtbody","rhtml","rnoInnerhtml","rchecked","rscriptType","rscriptTypeMasked","rcleanScript","wrapMap","option","legend","area","param","thead","tr","col","td","safeFragment","fragmentDiv","optgroup","tfoot","colgroup","caption","th","getAll","found","fixDefaultChecked","defaultChecked","manipulationTarget","content","disableScript","restoreScript","setGlobalEval","refElements","cloneCopyEvent","dest","oldData","curData","fixCloneNodeIssues","defaultSelected","dataAndEvents","deepDataAndEvents","destElements","srcElements","inPage","buildFragment","scripts","selection","wrap","safe","nodes","createTextNode","append","domManip","prepend","insertBefore","before","after","keepData","html","replaceWith","replaceChild","hasScripts","set","iNoClone","_evalUrl","appendTo","prependTo","insertAfter","replaceAll","insert","iframe","elemdisplay","actualDisplay","display","getDefaultComputedStyle","defaultDisplay","write","close","shrinkWrapBlocksVal","shrinkWrapBlocks","width","rmargin","rnumnonpx","getStyles","curCSS","rposition","getComputedStyle","opener","computed","minWidth","maxWidth","getPropertyValue","currentStyle","left","rs","rsLeft","runtimeStyle","pixelLeft","addGetHookIf","conditionFn","hookFn","condition","pixelPositionVal","boxSizingReliableVal","reliableHiddenOffsetsVal","reliableMarginRightVal","opacity","cssFloat","backgroundClip","clearCloneStyle","boxSizing","MozBoxSizing","WebkitBoxSizing","reliableHiddenOffsets","computeStyleTests","boxSizingReliable","pixelPosition","reliableMarginRight","marginRight","offsetHeight","swap","ralpha","ropacity","rdisplayswap","rnumsplit","rrelNum","cssShow","position","visibility","cssNormalTransform","letterSpacing","fontWeight","cssPrefixes","vendorPropName","capName","origName","showHide","show","hidden","setPositiveNumber","subtract","augmentWidthOrHeight","extra","isBorderBox","styles","getWidthOrHeight","valueIsBorderBox","cssHooks","cssNumber","columnCount","fillOpacity","flexGrow","flexShrink","lineHeight","order","orphans","widows","zIndex","cssProps","float","$1","margin","padding","border","prefix","suffix","expand","expanded","parts","hide","toggle","Tween","easing","unit","propHooks","run","percent","eased","duration","step","tween","fx","linear","p","swing","cos","PI","fxNow","timerId","rfxtypes","rfxnum","rrun","animationPrefilters","defaultPrefilter","tweeners","*","createTween","scale","maxIterations","createFxNow","genFx","includeWidth","height","animation","collection","opts","oldfire","checkDisplay","anim","dataShow","unqueued","overflow","overflowX","overflowY","propFilter","specialEasing","Animation","properties","stopped","tick","currentTime","startTime","tweens","originalProperties","originalOptions","gotoEnd","rejectWith","timer","complete","tweener","prefilter","speed","opt","speeds","fadeTo","to","animate","optall","doAnimation","finish","stopQueue","timers","cssFn","slideDown","slideUp","slideToggle","fadeIn","fadeOut","fadeToggle","interval","setInterval","clearInterval","slow","fast","delay","time","timeout","clearTimeout","getSetAttribute","hrefNormalized","checkOn","optSelected","enctype","optDisabled","radioValue","rreturn","valHooks","optionSet","scrollHeight","nodeHook","boolHook","ruseDefault","getSetInput","removeAttr","nType","attrHooks","propName","attrNames","propFix","getter","setAttributeNode","createAttribute","coords","contenteditable","rfocusable","rclickable","removeProp","for","class","notxml","tabindex","parseInt","rclass","addClass","classes","clazz","finalValue","proceed","removeClass","toggleClass","stateVal","classNames","hasClass","hover","fnOver","fnOut","bind","unbind","delegate","undelegate","nonce","rquery","rvalidtokens","JSON","parse","requireNonComma","depth","str","comma","open","Function","parseXML","DOMParser","parseFromString","ActiveXObject","async","loadXML","ajaxLocParts","ajaxLocation","rhash","rts","rheaders","rlocalProtocol","rnoContent","rprotocol","rurl","prefilters","transports","allTypes","addToPrefiltersOrTransports","structure","dataTypeExpression","dataType","dataTypes","inspectPrefiltersOrTransports","jqXHR","inspected","seekingTransport","inspect","prefilterOrFactory","dataTypeOrTransport","ajaxExtend","flatOptions","ajaxSettings","ajaxHandleResponses","s","responses","firstDataType","ct","finalDataType","mimeType","getResponseHeader","converters","ajaxConvert","response","isSuccess","conv2","current","conv","responseFields","dataFilter","active","lastModified","etag","url","isLocal","processData","contentType","accepts","json","* text","text html","text json","text xml","ajaxSetup","settings","ajaxPrefilter","ajaxTransport","ajax","cacheURL","responseHeadersString","timeoutTimer","fireGlobals","transport","responseHeaders","callbackContext","globalEventContext","completeDeferred","statusCode","requestHeaders","requestHeadersNames","strAbort","getAllResponseHeaders","setRequestHeader","lname","overrideMimeType","code","status","abort","statusText","finalText","success","method","crossDomain","traditional","hasContent","ifModified","headers","beforeSend","send","nativeStatusText","modified","getJSON","getScript","throws","wrapAll","wrapInner","unwrap","visible","r20","rbracket","rCRLF","rsubmitterTypes","rsubmittable","buildParams","v","encodeURIComponent","serialize","serializeArray","xhr","createStandardXHR","createActiveXHR","xhrId","xhrCallbacks","xhrSupported","cors","username","xhrFields","isAbort","onreadystatechange","responseText","XMLHttpRequest","script","text script","head","scriptCharset","charset","onload","oldCallbacks","rjsonp","jsonp","jsonpCallback","originalSettings","callbackName","overwritten","responseContainer","jsonProp","keepScripts","parsed","_load","params","animated","getWindow","offset","setOffset","curPosition","curLeft","curCSSTop","curTop","curOffset","curCSSLeft","calculatePosition","curElem","using","win","box","getBoundingClientRect","pageYOffset","pageXOffset","offsetParent","parentOffset","scrollTo","Height","Width","defaultExtra","funcName","size","andSelf","define","amd","_jQuery","_$","$","noConflict"],"mappings":";CAcC,SAAUA,EAAQC,GAEK,gBAAXC,SAAiD,gBAAnBA,QAAOC,QAQhDD,OAAOC,QAAUH,EAAOI,SACvBH,EAASD,GAAQ,GACjB,SAAUK,GACT,IAAMA,EAAED,SACP,KAAM,IAAIE,OAAO,2CAElB,OAAOL,GAASI,IAGlBJ,EAASD,IAIS,mBAAXO,QAAyBA,OAASC,KAAM,SAAUD,EAAQE,GAQnE,GAAIC,MAEAC,EAAQD,EAAWC,MAEnBC,EAASF,EAAWE,OAEpBC,EAAOH,EAAWG,KAElBC,EAAUJ,EAAWI,QAErBC,KAEAC,EAAWD,EAAWC,SAEtBC,EAASF,EAAWG,eAEpBC,KAKHC,EAAU,SAGVC,EAAS,SAA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GAI3B,IAAlBhB,EAAKyC,UACT0J,EAAMnM,EAAK+L,gBAIJrK,KAAKkC,IACX5D,EAAKkc,KAAM,SAAWlb,GAAQmL,EAAK,SAAWnL,GAC9ChB,EAAKkc,KAAM,SAAWlb,GAAQmL,EAAK,SAAWnL,GAC9CmL,EAAK,SAAWnL,KAIDQ,SAAV4B,EAENjF,EAAOyhB,IAAK5f,EAAMkC,EAAMmvB,GAGxBlzB,EAAO+e,MAAOld,EAAMkC,EAAMkB,EAAOiuB,IAChCnvB,EAAM4d,EAAY0S,EAAShxB,OAAWse,EAAW,WAOvD3hB,EAAOG,GAAGipC,KAAO,WAChB,MAAOjqC,MAAK4B,QAGbf,EAAOG,GAAGkpC,QAAUrpC,EAAOG,GAAG0Z,QAkBP,kBAAXyvB,SAAyBA,OAAOC,KAC3CD,OAAQ,YAAc,WACrB,MAAOtpC,IAOT,IAECwpC,IAAUtqC,EAAOc,OAGjBypC,GAAKvqC,EAAOwqC,CAwBb,OAtBA1pC,GAAO2pC,WAAa,SAAU1mC,GAS7B,MARK/D,GAAOwqC,IAAM1pC,IACjBd,EAAOwqC,EAAID,IAGPxmC,GAAQ/D,EAAOc,SAAWA,IAC9Bd,EAAOc,OAASwpC,IAGVxpC,SAMIZ,KAAawf,IACxB1f,EAAOc,OAASd,EAAOwqC,EAAI1pC,GAMrBA"} \ No newline at end of file diff --git a/assets/js/lesson.js b/assets/js/lesson.js old mode 100644 new mode 100755 index 185da92..c51dca6 --- a/assets/js/lesson.js +++ b/assets/js/lesson.js @@ -3,7 +3,7 @@ $("table").addClass("table table-striped"); // Handle foldable challenges and solutions (on click and at start). -$(".solution").click(function(event) { +$(".challenge,.discussion,.solution").click(function(event) { var trigger = $(event.target).has(".fold-unfold").size() > 0 || $(event.target).filter(".fold-unfold").size() > 0; if (trigger) { @@ -12,7 +12,7 @@ $(".solution").click(function(event) { event.stopPropagation(); } }); -$(".solution").each(function() { +$(".challenge,.discussion,.solution").each(function() { $(">*:not(h2)", this).toggle(); var h2 = $("h2:first", this); h2.append("<span class='fold-unfold glyphicon glyphicon-collapse-down'></span>"); diff --git a/bin/chunk-options.R b/bin/chunk-options.R old mode 100644 new mode 100755 diff --git a/bin/generate_md_episodes.R b/bin/generate_md_episodes.R old mode 100644 new mode 100755 index f2a40ba..6d8a2d7 --- a/bin/generate_md_episodes.R +++ b/bin/generate_md_episodes.R @@ -6,12 +6,12 @@ generate_md_episodes <- function() { if (!require("stringr")) stop("The package stringr is required for generating the lessons.") - if (require("checkpoint") && packageVersion("checkpoint") >= '0.4.0') { + if (require("checkpoint")) { required_pkgs <- - checkpoint:::scanForPackages(project = "_episodes_rmd", - verbose=FALSE, use.knitr = TRUE)$pkgs + checkpoint:::projectScanPackages(project = "_episodes_rmd", + verbose=FALSE, use.knitr = TRUE)$pkgs } else { - stop("The checkpoint package (>= 0.4.0) is required to build the lessons.") + stop("The checkpoint package is required to build the lessons.") } missing_pkgs <- required_pkgs[!(required_pkgs %in% rownames(installed.packages()))] @@ -22,7 +22,7 @@ generate_md_episodes <- function() { install.packages(missing_pkgs) } - ## find all the Rmd files, and generate the paths for their respective outputs + ## find all the Rmd files, and generates the paths for their respective outputs src_rmd <- list.files(pattern = "??-*.Rmd$", path = "_episodes_rmd", full.names = TRUE) dest_md <- file.path("_episodes", gsub("Rmd$", "md", basename(src_rmd))) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 8244222..311687e 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -14,7 +14,7 @@ from util import Reporter, read_markdown, load_yaml, check_unwanted_files, require, IMAGE_FILE_SUFFIX -__version__ = '0.3' +__version__ = '0.2' # Where to look for source Markdown files. SOURCE_DIRS = ['', '_episodes', '_extras'] @@ -48,10 +48,7 @@ P_FIGURE_REFS = re.compile(r'<img[^>]+src="([^"]+)"[^>]*>') # Pattern to match internally-defined Markdown links. -P_INTERNAL_LINK_REF = re.compile(r'\[([^\]]+)\]\[([^\]]+)\]') - -# Pattern to match reference links (to resolve internally-defined references). -P_INTERNAL_LINK_DEF = re.compile(r'^\[([^\]]+)\]:\s*(.+)') +P_INTERNALLY_DEFINED_LINK = re.compile(r'\[[^\]]+\]\[[^\]]+\]') # What kinds of blockquotes are allowed? KNOWN_BLOCKQUOTES = { @@ -106,8 +103,6 @@ def main(): args = parse_args() args.reporter = Reporter() check_config(args.reporter, args.source_dir) - args.references = read_references(args.reporter, args.reference_path) - docs = read_all_markdown(args.source_dir, args.parser) check_fileset(args.source_dir, args.reporter, docs.keys()) check_unwanted_files(args.source_dir, args.reporter) @@ -115,7 +110,6 @@ def main(): checker = create_checker(args, filename, docs[filename]) checker.check() check_figures(args.source_dir, args.reporter) - args.reporter.report() @@ -132,10 +126,6 @@ def parse_args(): default=None, dest='parser', help='path to Markdown parser') - parser.add_option('-r', '--references', - default=None, - dest='reference_path', - help='path to Markdown file of external references') parser.add_option('-s', '--source', default=os.curdir, dest='source_dir', @@ -161,46 +151,15 @@ def check_config(reporter, source_dir): config_file = os.path.join(source_dir, '_config.yml') config = load_yaml(config_file) reporter.check_field(config_file, 'configuration', config, 'kind', 'lesson') - reporter.check_field(config_file, 'configuration', config, 'carpentry', ('swc', 'dc', 'lc')) + reporter.check_field(config_file, 'configuration', config, 'carpentry', ('swc', 'dc')) reporter.check_field(config_file, 'configuration', config, 'title') - reporter.check_field(config_file, 'configuration', config, 'contact') + reporter.check_field(config_file, 'configuration', config, 'email') reporter.check({'values': {'root': '..'}} in config.get('defaults', []), 'configuration', '"root" not set to ".." in configuration') -def read_references(reporter, ref_path): - """Read shared file of reference links, returning dictionary of valid references - {symbolic_name : URL} - """ - - result = {} - urls_seen = set() - if ref_path: - with open(ref_path, 'r') as reader: - for (num, line) in enumerate(reader): - line_num = num + 1 - m = P_INTERNAL_LINK_DEF.search(line) - require(m, - '{0}:{1} not valid reference:\n{2}'.format(ref_path, line_num, line.rstrip())) - name = m.group(1) - url = m.group(2) - require(name, - 'Empty reference at {0}:{1}'.format(ref_path, line_num)) - reporter.check(name not in result, - ref_path, - 'Duplicate reference {0} at line {1}', - name, line_num) - reporter.check(url not in urls_seen, - ref_path, - 'Duplicate definition of URL {0} at line {1}', - url, line_num) - result[name] = url - urls_seen.add(url) - return result - - def read_all_markdown(source_dir, parser): """Read source files, returning {path : {'metadata':yaml, 'metadata_len':N, 'text':text, 'lines':[(i, line, len)], 'doc':doc}} @@ -315,7 +274,7 @@ def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): def check(self): - """Run tests.""" + """Run tests on metadata.""" self.check_metadata() self.check_line_lengths() @@ -383,16 +342,17 @@ def check_codeblock_classes(self): def check_defined_link_references(self): """Check that defined links resolve in the file. - Internally-defined links match the pattern [text][label]. + Internally-defined links match the pattern [text][label]. If + the label contains '{{...}}', it is hopefully a references to + a configuration value - we should check that, but don't right + now. """ result = set() for node in self.find_all(self.doc, {'type' : 'text'}): - for match in P_INTERNAL_LINK_REF.findall(node['value']): - text = match[0] - link = match[1] - if link not in self.args.references: - result.add('"{0}"=>"{1}"'.format(text, link)) + for match in P_INTERNALLY_DEFINED_LINK.findall(node['value']): + if '{{' not in match: + result.add(match) self.reporter.check(not result, self.filename, 'Internally-defined links may be missing definitions: {0}', @@ -481,14 +441,6 @@ class CheckEpisode(CheckBase): def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): super(CheckEpisode, self).__init__(args, filename, metadata, metadata_len, text, lines, doc) - - def check(self): - """Run extra tests.""" - - super(CheckEpisode, self).check() - self.check_reference_inclusion() - - def check_metadata(self): super(CheckEpisode, self).check_metadata() if self.metadata: @@ -515,26 +467,6 @@ def check_metadata_fields(self, expected): name, type(self.metadata[name]), type_) - def check_reference_inclusion(self): - """Check that links file has been included.""" - - if not self.args.reference_path: - return - - for (i, last_line, line_len) in reversed(self.lines): - if last_line: - break - - require(last_line, - 'No non-empty lines in {0}'.format(self.filename)) - - include_filename = os.path.split(self.args.reference_path)[-1] - if include_filename not in last_line: - self.reporter.add(self.filename, - 'episode does not include "{0}"', - include_filename) - - class CheckReference(CheckBase): """Check the reference page.""" diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py index fc7baf7..a3c478d 100755 --- a/bin/lesson_initialize.py +++ b/bin/lesson_initialize.py @@ -158,6 +158,7 @@ [dc-lessons]: http://datacarpentry.org/lessons/ [dc-site]: http://datacarpentry.org/ [discuss-list]: http://lists.software-carpentry.org/listinfo/discuss +[example-site]: https://swcarpentry.github.io/lesson-example/ [github]: http://github.com [github-flow]: https://guides.github.com/introduction/flow/ [github-join]: https://github.com/join @@ -174,16 +175,14 @@ # Values for this lesson. #------------------------------------------------------------ -# Which carpentry is this ("swc", "dc", or "lc")? +# Which carpentry is this ("swc" or "dc")? carpentry: "swc" # Overall title for pages. title: "Lesson Title" -# Contact. This *must* include the protocol: if it's an email -# address, it must look like "mailto:lessons@software-carpentry.org", -# or if it's a URL, "https://gitter.im/username/ProjectName". -contact: "mailto:lessons@software-carpentry.org" +# Contact email address. +email: lessons@software-carpentry.org #------------------------------------------------------------ # Generic settings (should not need to change). @@ -202,7 +201,6 @@ swc_github: "https://github.com/swcarpentry" swc_site: "https://software-carpentry.org" swc_pages: "https://swcarpentry.github.io" -lc_site: "http://librarycarpentry.github.io/" template_repo: "https://github.com/swcarpentry/styles" example_repo: "https://github.com/swcarpentry/lesson-example" example_site: "https://swcarpentry.github.com/lesson-example" @@ -213,7 +211,6 @@ # Surveys. pre_survey: "https://www.surveymonkey.com/r/swc_pre_workshop_v1?workshop_id=" post_survey: "https://www.surveymonkey.com/r/swc_post_workshop_v1?workshop_id=" -training_post_survey: "https://www.surveymonkey.com/r/post-instructor-training" # Start time in minutes (0 to be clock-independent, 540 to show a start at 09:00 am). start_time: 0 @@ -278,45 +275,6 @@ FIXME ''' -ROOT_AIO_MD = '''\ ---- -layout: page -permalink: /aio/ ---- -<script> - window.onload = function() { - var lesson_episodes = [ - {% for episode in site.episodes %} - "{{ episode.url}}"{% unless forloop.last %},{% endunless %} - {% endfor %} - ]; - var xmlHttp = []; /* Required since we are going to query every episode. */ - for (i=0; i < lesson_episodes.length; i++) { - xmlHttp[i] = new XMLHttpRequest(); - xmlHttp[i].episode = lesson_episodes[i]; /* To enable use this later. */ - xmlHttp[i].onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - var article_here = document.getElementById(this.episode); - var parser = new DOMParser(); - var htmlDoc = parser.parseFromString(this.responseText,"text/html"); - var htmlDocArticle = htmlDoc.getElementsByTagName("article")[0]; - article_here.innerHTML = htmlDocArticle.innerHTML; - } - } - episode_url = "{{ page.root }}" + lesson_episodes[i]; - xmlHttp[i].open("GET", episode_url); - xmlHttp[i].send(null); - } - } -</script> -{% comment %} -Create anchor for each one of the episodes. -{% endcomment %} -{% for episode in site.episodes %} -<article id="{{ episode.url }}"></article> -{% endfor %} -''' - EPISODES_INTRODUCTION_MD = '''\ --- title: "Introduction" @@ -379,7 +337,6 @@ ('index.md', ROOT_INDEX_MD), ('reference.md', ROOT_REFERENCE_MD), ('setup.md', ROOT_SETUP_MD), - ('aio.md', ROOT_AIO_MD), ('_episodes/01-introduction.md', EPISODES_INTRODUCTION_MD), ('_extras/about.md', EXTRAS_ABOUT_MD), ('_extras/discuss.md', EXTRAS_DISCUSS_MD), diff --git a/bin/util.py b/bin/util.py old mode 100644 new mode 100755 diff --git a/code/.gitkeep b/code/.gitkeep old mode 100644 new mode 100755 diff --git a/commands.mk b/commands.mk deleted file mode 100644 index 0a00c72..0000000 --- a/commands.mk +++ /dev/null @@ -1,2 +0,0 @@ -fig/catfood-tree.png: fig/catfood-tree.dot - dot -Tpng < "$<" > "$@" diff --git a/data/.gitkeep b/data/.gitkeep old mode 100644 new mode 100755 diff --git a/favicon-dc.ico b/favicon-dc.ico old mode 100644 new mode 100755 diff --git a/favicon-lc.ico b/favicon-lc.ico deleted file mode 100644 index f4f3c93..0000000 Binary files a/favicon-lc.ico and /dev/null differ diff --git a/favicon-swc.ico b/favicon-swc.ico old mode 100644 new mode 100755 diff --git a/fig/.gitkeep b/fig/.gitkeep old mode 100644 new mode 100755 diff --git a/fig/canparl.png b/fig/canparl.png new file mode 100755 index 0000000..e914035 Binary files /dev/null and b/fig/canparl.png differ diff --git a/fig/catfood-tree.dot b/fig/catfood-tree.dot deleted file mode 100644 index a046836..0000000 --- a/fig/catfood-tree.dot +++ /dev/null @@ -1,27 +0,0 @@ -digraph G { - dpi = 80; - - node [ shape=box; style=solid ]; - - node [ color=green ]; - roottype [ label="Attribute:\ntype='basic'"; ]; - addressclass [ label="Attribute:\nclass='USA'" ]; - - node [ color=red ]; - manufacturertext [ label="Text:\nPurina" ]; - addresstext [ label="Text:\n12 Cat Way ..." ]; - datetext [ label="Text:\n2019-10-01" ]; - - node [ style=bold; color=blue ]; - root [ label="Root element:\n<catfood>" ]; - manufacturer [ label="Element:\n<manufacturer>" ]; - contact [ label="Element:\n<contact>" ]; - address [ label="Element:\n<address>" ]; - date [ label="Element:\n<date>" ]; - - root -> roottype; - root -> manufacturer -> manufacturertext; - root -> contact -> address -> addressclass; - address -> addresstext; - root -> date -> datetext; -} diff --git a/fig/catfood-tree.png b/fig/catfood-tree.png deleted file mode 100644 index bb4bef7..0000000 Binary files a/fig/catfood-tree.png and /dev/null differ diff --git a/fig/firefox-console.png b/fig/firefox-console.png old mode 100644 new mode 100755 diff --git a/fig/firefox-hover.png b/fig/firefox-hover.png old mode 100644 new mode 100755 diff --git a/fig/importio-ontparl-01.png b/fig/importio-ontparl-01.png old mode 100644 new mode 100755 diff --git a/fig/importio-ontparl-02.png b/fig/importio-ontparl-02.png old mode 100644 new mode 100755 diff --git a/fig/importio-ontparl-03.png b/fig/importio-ontparl-03.png old mode 100644 new mode 100755 diff --git a/fig/importio-ontparl-04.png b/fig/importio-ontparl-04.png old mode 100644 new mode 100755 diff --git a/fig/importio-ontparl-05.png b/fig/importio-ontparl-05.png old mode 100644 new mode 100755 diff --git a/fig/importio-ontparl-06.png b/fig/importio-ontparl-06.png old mode 100644 new mode 100755 diff --git a/fig/importio-ontparl-07.png b/fig/importio-ontparl-07.png old mode 100644 new mode 100755 diff --git a/fig/importio-ontparl-08.png b/fig/importio-ontparl-08.png old mode 100644 new mode 100755 diff --git a/fig/scraper-canparl-01.png b/fig/scraper-canparl-01.png old mode 100644 new mode 100755 diff --git a/fig/scraper-canparl-02.png b/fig/scraper-canparl-02.png old mode 100644 new mode 100755 diff --git a/fig/scraper-canparl-03.png b/fig/scraper-canparl-03.png old mode 100644 new mode 100755 diff --git a/fig/scraper-canparl-04.png b/fig/scraper-canparl-04.png old mode 100644 new mode 100755 diff --git a/fig/scraper-canparl-05.png b/fig/scraper-canparl-05.png old mode 100644 new mode 100755 diff --git a/fig/scraper-contextmenu.png b/fig/scraper-contextmenu.png old mode 100644 new mode 100755 diff --git a/fig/scraper-menu.png b/fig/scraper-menu.png old mode 100644 new mode 100755 diff --git a/fig/scraper-ontparl-01.png b/fig/scraper-ontparl-01.png old mode 100644 new mode 100755 diff --git a/fig/scraper-ontparl-02.png b/fig/scraper-ontparl-02.png old mode 100644 new mode 100755 diff --git a/fig/scraper-ukparl-01.png b/fig/scraper-ukparl-01.png old mode 100644 new mode 100755 diff --git a/fig/scraper-ukparl-02.png b/fig/scraper-ukparl-02.png old mode 100644 new mode 100755 diff --git a/fig/ukparl.png b/fig/ukparl.png old mode 100644 new mode 100755 diff --git a/fig/unscr-fragment.png b/fig/unscr-fragment.png deleted file mode 100644 index bf64dbc..0000000 Binary files a/fig/unscr-fragment.png and /dev/null differ diff --git a/fig/web-scraper-click-year-for-preview.png b/fig/web-scraper-click-year-for-preview.png deleted file mode 100644 index a7c4101..0000000 Binary files a/fig/web-scraper-click-year-for-preview.png and /dev/null differ diff --git a/fig/web-scraper-create.png b/fig/web-scraper-create.png deleted file mode 100644 index bc57891..0000000 Binary files a/fig/web-scraper-create.png and /dev/null differ diff --git a/fig/web-scraper-data-preview-1999bad.png b/fig/web-scraper-data-preview-1999bad.png deleted file mode 100644 index 1214c70..0000000 Binary files a/fig/web-scraper-data-preview-1999bad.png and /dev/null differ diff --git a/fig/web-scraper-data-preview.png b/fig/web-scraper-data-preview.png deleted file mode 100644 index ebd1d9f..0000000 Binary files a/fig/web-scraper-data-preview.png and /dev/null differ diff --git a/fig/web-scraper-data-preview2.png b/fig/web-scraper-data-preview2.png deleted file mode 100644 index e9a243c..0000000 Binary files a/fig/web-scraper-data-preview2.png and /dev/null differ diff --git a/fig/web-scraper-dropdown-scrape.png b/fig/web-scraper-dropdown-scrape.png deleted file mode 100644 index 39ed196..0000000 Binary files a/fig/web-scraper-dropdown-scrape.png and /dev/null differ diff --git a/fig/web-scraper-empty-selector-list.png b/fig/web-scraper-empty-selector-list.png deleted file mode 100644 index 42de823..0000000 Binary files a/fig/web-scraper-empty-selector-list.png and /dev/null differ diff --git a/fig/web-scraper-select-popup.png b/fig/web-scraper-select-popup.png deleted file mode 100644 index 8b317ad..0000000 Binary files a/fig/web-scraper-select-popup.png and /dev/null differ diff --git a/fig/web-scraper-unsc-bar-chart.png b/fig/web-scraper-unsc-bar-chart.png deleted file mode 100644 index cdf0f33..0000000 Binary files a/fig/web-scraper-unsc-bar-chart.png and /dev/null differ diff --git a/fig/web-scraper-unsc-graph.png b/fig/web-scraper-unsc-graph.png deleted file mode 100644 index 1084cb0..0000000 Binary files a/fig/web-scraper-unsc-graph.png and /dev/null differ diff --git a/fig/web-scraper-year-selector.png b/fig/web-scraper-year-selector.png deleted file mode 100644 index 630dd17..0000000 Binary files a/fig/web-scraper-year-selector.png and /dev/null differ diff --git a/fig/xpath-axes.jpg b/fig/xpath-axes.jpg old mode 100644 new mode 100755 diff --git a/fig/xpath-treeview.png b/fig/xpath-treeview.png old mode 100644 new mode 100755 diff --git a/files/.gitkeep b/files/.gitkeep old mode 100644 new mode 100755 diff --git a/index.md b/index.md old mode 100644 new mode 100755 index a198b11..087bf63 --- a/index.md +++ b/index.md @@ -7,31 +7,32 @@ Web scraping is the process of extracting data from websites. Some data that is presented in a format that makes it easier to collect and use it, for example in the form of downloadable comma-separated values (CSV) datasets that can then be imported in a spreadsheet or loaded into a data analysis script. Often however, even though it is publicly available, data is not readily available for reuse. -For example, it can be contained in a PDF, or a table on a website, or spread across multiple web pages. +For example it can be contained in a PDF, or a table on a website, or spread across multiple web pages. There are a variety of ways to _scrape_ a website to extract information for reuse. In its simplest form, this can be achieved by -copying and pasting snippets from a web page, but this can be impractical if there is a large amount of data to -be extracted or if it is spread over a large number of pages. Instead, specialized tools and techniques can be used -to automate this process by defining what sites to visit, what information to look for, and whether data extraction -should stop at the end of a page or follow hyperlinks to repeat the process recursively. -Automating web scraping also allows for defining whether the process should be run at regular intervals in order to capture changes +copying and pasting snippets from a web page, but this can be unpractical if there is a large amount of data to +be extracted, or if it spread over a large number of pages. Instead, specialized tools and techniques can be used +to automate this process, by defining what sites to visit, what information to look for, and whether data extraction +should stop once the end of a page has been reached, or whether to follow hyperlinks and repeat the process recursively. +Automating web scraping also allows to define whether the process should be run at regular intervals and capture changes in the data. > ## Prerequisites > -> As web scraping is a technique to extract data from web pages, it requires some understanding of +> As webscraping is a technique to extract data from web pages, it requires some understanding of > the technologies that are used to display information on the web. > This lesson therefore assumes that learners will have some familiarity with [HTML](https://en.wikipedia.org/wiki/HTML) > and the [Document Object Model](https://en.wikipedia.org/wiki/Document_Object_Model) (DOM). > > The first part of this lesson will use browser extensions to introduce the concepts of web scraping -> as well as introduce the CSS selector syntax for selecting elements on a web page +> as well as introduce the XPath syntax for selecting elements on a web page > and requires no further specific knowledge. > The second part will introduce the use of specialized libraries to scrape websites by writing > custom computer programs and will require some familiarity with the -> [Python programming language](https://swcarpentry.github.io/python-novice-inflammation/). +> [Python programming language](https://swcarpentry.github.io/python-novice-inflammation/) +> and [object-oriented programming](https://en.wikipedia.org/wiki/Object-oriented_programming). > {: .prereq} @@ -42,7 +43,7 @@ Refer to the [Setup](setup/) section to install the required software to follow > ## Under development > > Please note that the contents of this lesson are still being actively developed. Any feedback is -> appreciated, please do not hesitate to contact [the maintainers]({{ site.contact }}) or contribute -> to the lesson by [forking it on GitHub]({{ site.github.repository_url }}). +> appreciated, please do not hesitate to contact [the author](mailto:tom@timtom.ch) or contribute +> to the lesson by [forking it on GitHub](https://github.com/timtomch/library-webscraping/). > -{: .callout} +{: .callout} \ No newline at end of file diff --git a/reference.md b/reference.md old mode 100644 new mode 100755 diff --git a/setup.md b/setup.md old mode 100644 new mode 100755 index 3b12506..8f41c9f --- a/setup.md +++ b/setup.md @@ -3,147 +3,52 @@ layout: page title: Setup permalink: /setup/ --- +In order to follow this lesson, you will need to make sure the following software is installed on your computer. -# Google Chrome requirements +## Part one: Manually scrape data using browser extensions -For the episode on visual scraping in your web browser, the following are required: +For the first half of the lesson, we will use a Chrome browser extension to get started with web scraping. -* [Google Chrome for Desktop](https://www.google.com/chrome/browser/desktop/) -* [Web Scraper extension](http://chrome.google.com/webstore/detail/web-scraper/jnhgnonknehpejjnehehllkliplmbmhn): click _Add to Chrome_ +1. Please ensure you have a working copy of the [Chrome browser](https://www.google.com/intl/en/chrome/browser/). +2. Using Chrome, download and enable the [Scraper extension](https://chrome.google.com/webstore/detail/scraper/mbigbapnjcgaffohmbkdlecaccepngjd). -# Python requirements +## Part two: Write Python programs to automatically scrape data -We will be using [Anaconda][anaconda] for the episode on scraping in Python, as it includes all of the necessary -requirements. If you don't wish to install Anaconda, you will need to install each requirement -separately. This document only details installation with Anaconda. +### Shell and Python +The second part of the lesson requires the Python programming language and access to a command-line interface (shell) on your computer. +Please refer to [the Software Carpentry setup instructions](http://swcarpentry.github.io/workshop-template/#setup) for +*the Bash shell* and *Python* if you need guidance. -Please set up your Python environment prior to the workshop. If you encounter problems with the -installation procedure, ask your workshop organizers via e-mail for assistance, so you are ready -to go when the workshop begins. +> ## Prerequisites +> This part of the lesson requires some prior knowledge of Python and how to use a shell. +> If you need help getting started on those topics, we suggest going through the following +> lessons first (during a workshop or on your own): +> +> * [The Unix Shell](http://swcarpentry.github.io/shell-novice/) +> * [Programming with Python](http://swcarpentry.github.io/python-novice-inflammation/) +> +{: .prereq} -**Recommended:** +### Scrapy -* [Anaconda](#anaconda) +Once you have a working installation of Python, the next step is to install [Scrapy](https://scrapy.org/). -Optional (already provided with Anaconda): +If you have installed Python using the Anaconda framework as suggested by the Software Carpentry setup instructions, +you can easilly install Scrapy by doing the following: -* [Python 3.x](#python) -* [Spyder 3](#spyder) -* [lxml](#lxml): a recent version -* [cssselect](#cssselect) -* [Requests](#reqeusts) +1. Open a new shell (e.g. Terminal on Mac, or the Anaconda command-line tool on Windows) +2. Type the following: -<a name="anaconda"></a> +> conda install -c conda-forge scrapy +> +{: .source} -## Installing all requirements using Anaconda +Alternatively, if you have another distribution of Python, you can try using pip: -[Python][python] is a great language for general-purpose programming, and it even has tools -available that help with web scraping. Installing each of the additional tools for this lesson -individually can be a bit difficult, so we recommend the all-in-one installer [Anaconda][anaconda]. +> pip install Scrapy +> +{: .source} -Regardless of how you choose to install it, please make sure you install Python version 3.x -(e.g., Python 3.6 version). - -### Windows - [Video tutorial][video-windows] - -1. Open [http://continuum.io/downloads][continuum-windows] with your web browser. - -2. Download the Python 3.x version installer for Windows. - -3. Double-click the executable and install Python 3 using _MOST_ of the default settings. - The only exception is to check the **Make Anaconda the default Python** option. - -### macOS - [Video tutorial][video-mac] - -1. Open [http://continuum.io/downloads][continuum-mac] with your web browser. - -2. Download the Python 3.x version Graphical Installer for macOS. - -3. Install Python 3 using all of the defaults for installation. - -### Linux - -Note that the following installation steps require you to work from the shell. -If you run into any difficulties, please request help before the workshop begins. - -1. Open [http://continuum.io/downloads][continuum-linux] with your web browser. - -2. Download the Python 3.x version installer for Linux. - -3. Install Python 3 using all of the defaults for installation. - - a. Open a terminal window. - - b. Navigate to the folder where you downloaded the installer - - c. Type - - ~~~ - $ bash Anaconda3- - ~~~ - {: .bash} - - and press tab. The name of the file you just downloaded should appear. - - d. Press enter. - - e. Follow the text-only prompts. When the license agreement appears (a colon - will be present at the bottom of the screen) hold the down arrow until the - bottom of the text. Type `yes` and press enter to approve the license. Press - enter again to approve the default location for the files. Type `yes` and - press enter to prepend Anaconda to your `PATH` (this makes the Anaconda - distribution the default Python). - -## Optional installation method - -If you've opted to install the requirements separately (not recommended), you will find links to -them below. - -* <a name="python"></a> [Python 3.x][python-install] -* <a name="spyder"></a> [Spyder 3][spyder-install] -* <a name="lxml"></a> [lxml][lxml-install] -* <a name="cssselect"></a> [cssselect][cssselect-install] -* <a name="requests"></a> [Requests][requests-install] - -With [Miniconda](https://conda.io/miniconda.html) for Python 3 installed, the following can be entered on the terminal command line to install all of the required packages: - -~~~ -conda install spyder lxml cssselect requests -~~~ -{: .bash} - -## Starting Python - -We will use the [Spyder IDE][spyder], the same IDE used in the Library Carpentry Python course. -If you installed Python using Anaconda, Spyder is already on your system. - -To start Spyder, open a terminal and type the command: - -On Windows and Linux: - -~~~ -$ spyder -~~~ -{: .bash} - -On Mac: - -~~~ -$ spyder3 -~~~ -{: .bash} - -[anaconda]: https://www.continuum.io/anaconda -[continuum-windows]: http://continuum.io/downloads#windows -[continuum-mac]: http://continuum.io/downloads#macos -[continuum-linux]: http://continuum.io/downloads#linux -[python-install]: https://www.python.org/downloads/ -[spyder-install]: https://pythonhosted.org/spyder/installation.html -[lxml-install]: http://lxml.de/installation.html -[cssselect-install]: https://pypi.python.org/pypi/cssselect -[requests-install]: http://docs.python-requests.org/en/master/user/install/#install -[python]: https://python.org -[spyder]: https://pythonhosted.org/spyder/ -[spyder-install]: https://pythonhosted.org/spyder/installation.html -[video-mac]: https://www.youtube.com/watch?v=TcSAln46u9U -[video-windows]: https://www.youtube.com/watch?v=xxQ0mzZ8UvA +If you run into issues while installing Scrapy, refer to the +[official Scrapy install guide](https://doc.scrapy.org/en/latest/intro/install.html#intro-install) +or get in touch with your lesson instructor.