cobrateam / django-htmlmin

HTML minifier for Python frameworks (not only Django, despite the name).
http://pypi.python.org/pypi/django-htmlmin
BSD 2-Clause "Simplified" License
542 stars 73 forks source link

why?sometimes it can run,sometimes it raise a except as follows:File "C:\Python34\lib\site-packages\bs4\__init__.py", line 192, in __init__ elif len(markup) <= 256 and ( TypeError: object of type 'NoneType' has no len() #125

Closed TangGrit closed 6 years ago

TangGrit commented 6 years ago

import requests from bs4 import BeautifulSoup

def getHTMLText(url): try: r = requests.get(url,timeout=30) r.raise_for_status() r.encoding = 'gb2312' return r.text except: retun r.raise_for_status() def main(): url = 'http://www.okooo.com/soccer/match/156622/odds/change/14/' html = getHTMLText(url) main()