Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why? #126

Open
TangGrit opened this issue Jul 2, 2018 · 2 comments
Open

why? #126

TangGrit opened this issue Jul 2, 2018 · 2 comments

Comments

@TangGrit
Copy link

TangGrit commented Jul 2, 2018

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()

@TangGrit
Copy link
Author

TangGrit commented Jul 2, 2018

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?

@TangGrit TangGrit closed this as completed Jul 2, 2018
@TangGrit TangGrit reopened this Jul 2, 2018
@andrewsmedina
Copy link
Member

which django version are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants