You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the website can be open by clicked from a hyperlink,but the codes sometimes can run in python3.x,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().
how to change the codes in order to run in all times,rather than raising a except?
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()
The text was updated successfully, but these errors were encountered: