-2

I wrote code in python that use the HTML source, using BeautifulSoup. The HTML I'm getting is very messy. How can I make the HTML source look nicely?

Here's the website

This is how I'm getting the html source (part of it):

    property="article:tag" content="ally" /><meta
property="article:tag" content="harvey weinstein" /><meta
property="article:tag" content="pratiksha parulekar" /><meta
property="article:tag" content="rape culture" /><meta
property="article:section" content="No Photo" /><meta
property="article:published_time" content="2017-10-25T22:28:46-05:00" /><meta
property="article:modified_time" content="2017-10-25T22:44:29-05:00" /><meta
property="og:updated_time" content="2017-10-25T22:44:29-05:00" /><meta
name="twitter:card" content="summary" /><meta
name="twitter:description" content="For men, professing disgust at sexual assault allegations is not sufficient; male allies must also hold friends who harass women accountable." /><meta
name="twitter:title" content="To combat sexual harassment, men must hold peers accountable &bull; The Tulane Hullabaloo" /><link
rel='dns-prefetch' href='//cdn.jsdelivr.net' /><link
rel='dns-prefetch' href='//maxcdn.bootstrapcdn.com' /><link
rel='dns-prefetch' href='//fonts.googleapis.com' /><link
rel='dns-prefetch' href='//s.w.org' /><link

What can i do?

baduker
  • 19,152
  • 9
  • 33
  • 56
Elior Sastiel
  • 1,074
  • 2
  • 10
  • 21
  • 1
    *"Beauty is in the eye of the beholder"*. What do you mean by "Look Nice"? I don't really think that this is a programming question. – SiHa Mar 29 '18 at 07:20
  • look the html source that i add. the open tag is located at the end. @s – Elior Sastiel Mar 29 '18 at 07:21
  • Possible duplicate of [Python : How to Pretty print html into a file](https://stackoverflow.com/questions/6150108/python-how-to-pretty-print-html-into-a-file) – Keyur Potdar Mar 29 '18 at 07:38

2 Answers2

2

You might be looking for the doc

print(yoursoup.prettify())
Guillaume
  • 5,497
  • 3
  • 24
  • 42
1

If you want to 'prettify' the HTML, as you are using Beautiful Soup, you can do something in here.

Bear in mind that the import has changed since that answer and it's now:

from bs4 import BeautifulSoup

Probably some fields changed since then, you can find more examples in the documentation

Mangu
  • 3,160
  • 2
  • 25
  • 42