# Need help in parsing page using Python

**URL:** <https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791>\
**Category:** General\
**Created:** [May 27, 2020, 3:39am UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791 "2020-05-27T03:39:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashishdalvi3](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ashishdalvi3/32/150836_2.png) [@ashishdalvi3](https://forum.freecodecamp.org/u/ashishdalvi3)\
**Post date:** [May 27, 2020, 3:39am UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791/1 "2020-05-27T03:39:28Z")

</div>

I am trying to parse MS URL [https://support.microsoft.com/en-us/help/4462242/description-of-the-security-update-for-office-2016-april-9-2019](https://support.microsoft.com/en-us/help/4462242/description-of-the-security-update-for-office-2016-april-9-2019)

I need to get 2 tables under File Information

1. For all supported x86-based versions
2. For all supported x64-based versions

However when i try to use beautiful soup i am not able to parse table object as it is inside tag

Any points will be appreciated.

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 27, 2020, 6:55am UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791/2 "2020-05-27T06:55:59Z")

</div>

import pandas as pd  
import requests  
from bs4 import BeautifulSoup  
import re

url = ‘[https://support.microsoft.com/en-us/help/4462242/description-of-the-security-update-for-office-2016-april-9-2019](https://support.microsoft.com/en-us/help/4462242/description-of-the-security-update-for-office-2016-april-9-2019)’  
soup = BeautifulSoup(requests.get(url).text)  
data = soup.findAll(‘script’)[10].string  
match = re.search(r’For all supported x86-based versions of Office 2016(.\*)’, data)  
d = match.group()  
pd.read\_html(d)

packages you’ll need to install:  
pandas  
requests  
html5lib  
bs4  
lxml

# note the apostrophes are not displayed correctly in this editor.

I only did the top link, I’m sure you can get the other one. GL.

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 27, 2020, 6:57am UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791/3 "2020-05-27T06:57:12Z")

</div>

Way easier to just use Javascript if this is a one time thing.

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 27, 2020, 7:23am UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791/4 "2020-05-27T07:23:35Z")

</div>

```auto
let tables = [...document.querySelectorAll('table');
tables.shift();

const columns = ['file_identifier', 'file_name', 'file_version', 'file_size', 'date', 'time'];

let x = tables.map((table) => [...table.querySelectorAll('tr')].map((tr, i) => { 
   if (i === 0) return null;
   return [...tr.children].reduce((a, b, i) => {
     return {...a, [columns[i]]: b.innerText};
   }, {})
}))

console.log(x);

```

 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/a/7/a7124af3c9384154faa8f751e02f9d10b53fc550.png)

I would just post the JSON in here, but then the mod police would pull me over.

Be sure to click both links before running this code. The tables must be added to DOM first.

---

<div class="post-metadata">

**Author:** ![ashishdalvi3](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ashishdalvi3/32/150836_2.png) [@ashishdalvi3](https://forum.freecodecamp.org/u/ashishdalvi3)\
**Post date:** [May 27, 2020, 8:30am UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791/5 "2020-05-27T08:30:21Z")

</div>

first solution worked for me.  
but there is still need to parse data i get from regex.Thanks a lot

---

<div class="post-metadata">

**Author:** ![ashishdalvi3](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ashishdalvi3/32/150836_2.png) [@ashishdalvi3](https://forum.freecodecamp.org/u/ashishdalvi3)\
**Post date:** [May 27, 2020, 8:31am UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791/6 "2020-05-27T08:31:15Z")

</div>

i might have to think of creating more of generic solution as there are lots of pages which i need to parse

---

<div class="post-metadata">

**Author:** ![martinjus](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@martinjus](https://forum.freecodecamp.org/u/martinjus)\
**Post date:** [May 27, 2020, 9:00am UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791/7 "2020-05-27T09:00:34Z")

</div>

first solution worked for me.  
but there is still need to parse data i get from regex.Thanks a lot

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:51pm UTC](https://forum.freecodecamp.org/t/need-help-in-parsing-page-using-python/394791/8 "2021-06-01T18:51:57Z")

</div>

Closed on June 1, 2021, 6:51pm UTC


