试图使解析器网站成为myscore希望它从实时比赛中收集数据。当您创建代码时出现以下错误。下面的错误
帮助解决此问题! ;(
错误:
Traceback (most recent call last):
File "test.py", line 22, in <module>
print(soup.prettify('self'))
File "C:\Users\antst\AppData\Local\Programs\Python\Python35\lib\site-packages\bs4\element.py", line 1222, in prettify
return self.decode(True, formatter=formatter)
AttributeError: 'str' object has no attribute 'decode'
代码:
#Parsing of the website myscore
import requests
import urllib.request`enter code here`
import urllib as ur
import urllib
from bs4 import BeautifulSoup
from urllib.request import urlopen, Request
from urllib import request
from urllib.request import Request, urlopen
url = 'https://www.myscore.ru'
response = requests.get(url)
urllib.request.urlopen (url)
with urllib.request.urlopen("https://www.myscore.ru", timeout=1) as url:
req = Request('https://www.myscore.ru', headers={'User-Agent': 'Mozilla/5.0'})
webpage = urlopen(req).read()
from bs4 import BeautifulSoup
soup = BeautifulSoup
print(soup.prettify('self'))