Parse html failed with BeautifulSoup and requests, I can't figure it out, can anyone tell me why?

Here is my code:

import requests
from bs4 import BeautifulSoup 
r = requests.get(self.url)
soup = BeautifulSoup(r.content)
print r.content # Here, I got output of the html
print soup.text # Here, I can't get any output, which puzzled me.

It may be what reason/reasons caused this?

Thank you guys!


I got it!

Because the BS didn't parse the document correctly, so it lost some content.

The solution is:

soup = BeautifulSoup(r.content, 'html.parser')

Need Your Help

What is the token for unsigned short in Objective-C?

objective-c token

What are the token for unsigned short in objective-c?

Update parameter on click

javascript jquery

I have a script that adds a parameter to the url on a click - and replaces the the parameter with another on the second click. This works great.