Skip to content
Advertisement

Accessing the contents on links provided on a webpage while webscraping

This is a followup question of my previous question. I am trying to access the contents of a webpage.

I could search for contents on the webpage. However, I am not sure how to access the contents in links given on the webpage.

For instance, the first line of the search result for id 1.1.1.1 is 36EUL/ADL_7 1.1.1.1 spectrophotometry .... C ....

The secondary id 36EUL/ADL_7, in the first line, has another link that opens when clicked.

I am not sure how to access the contents of the search result of the secondary id.

Any suggestions?

EDIT:

The solution posted by Sers works for search_term = 1.1.1.1 with the following output format( same as the obtained output)

JavaScript

However, for a different search term, i.e. search_term = 2.7.2.3

Output obtained: (fails because the output table in the database has 4 columns excluding reference id)

JavaScript

Expected output:

JavaScript

lines 85-87 , isn’t the correct assignment always.

JavaScript

My suggestion is ,

Can we map the column name and the corresponding values while parsing the values from columns?

JavaScript

Advertisement

Answer

All can be done using Requests and BeautifulSoup without Selenium. Here code how to get data with details:

JavaScript

Output of some values:

EC Number: 1.1.1.1, Reference Id: 36EUL/ADL_7, Evaluation: C
T(K): 298.15, pH: 6.4, K’: 1.3E-5
T(K): 298.15, pH: 7.0, K’: 5.3E-5
T(K): 298.15, pH: 7.7, K’: 1.3E-4

EC Number: 1.1.1.1, Reference Id: 37ADL/SRE_8, Evaluation: D
T(K): 298.15, pH: 6.05, K’: 6.0E-6
T(K): 298.15, pH: 7.25, K’: 7.7E-5
T(K): 298.15, pH: 8.0, K’: 1.2E-5

EC Number: 1.1.1.1, Reference Id: 37NEG/WUL_9, Evaluation: C
T(K): 293.15, pH: 7.9, K’: 7.41E-4

EC Number: 1.1.1.1, Reference Id: 38SCH/HEL_10, Evaluation: C
T(K): 298.15, pH: 6.30, K’: 2.6E-5
T(K): 298.15, pH: 6.85, K’: 8.8E-5
T(K): 298.15, pH: 7.15, K’: 1.9E-4
T(K): 298.15, pH: 7.34, K’: 3.0E-4
T(K): 298.15, pH: 7.61, K’: 5.1E-4
T(K): 298.15, pH: 7.77, K’: 8.0E-4
T(K): 298.15, pH: 8.17, K’: 2.2E-3

EC Number: 1.1.1.1, Reference Id: 38SCH/HEL_23, Evaluation: C
T(K): 298.15, pH: 6.39, K’: 9.1E-6
T(K): 298.15, pH: 6.60, K’: 3.0E-5
T(K): 298.15, pH: 6.85, K’: 5.1E-5
T(K): 298.15, pH: 7.18, K’: 1.5E-4
T(K): 298.15, pH: 7.31, K’: 2.3E-4
T(K): 298.15, pH: 7.69, K’: 5.6E-4
T(K): 298.15, pH: 8.06, K’: 1.1E-3

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement