Skip to content
Advertisement

Parsing a pre tag in html, how to append the indented text to the previous line in Python

Example URL https://bioconductor.org/packages/release/bioc/VIEWS

Currently I’m splitting each individual clump of metadata by every blank line, then converting to a dictionary splitting on the first colon using the string before as the key and the string after as the value. THE ISSUE I’m running is that I am going line by line through each package metadata, some lines do not have colons and I want to append that to the previous value as one complete string.

JavaScript

Advertisement

Answer

Try using regex to parse the data:

JavaScript

Prints:

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