Step 2 – Scraping information from the Wiki page

As we need to start from something, let's pick a battle page to test our code on – Operation Skorpion (en.wikipedia.org//wiki/Operation_Skorpion). The following is a screenshot of the page, with the areas in which we're interested highlighted in red:

The code for this part of the chapter is stored in the B_Scraping_part_2 notebook.

First, we can use the function we wrote in the earlier section to collect the page as a dom object:

url = 'https://en.wikipedia.org/wiki/Opeation_Scorpion'
dom = get_dom(url)

Next, as in the previous case, we select the larger container that stores all the information we're interested in – in this case, the info card (the larger, dotted red rectangle on the screenshot). All the information we're interested in (dates, location, outcomes, belligerents, and casualties) is there, below the map:

table = dom.find('table','infobox vevent')

Now that we have the card, all we need is to pull all the information out of it, which we'll do in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.23.101.63