Answer the question
In order to leave comments, you need to log in
Why does it give an error when parsing?
import requests
from bs4 import BeautifulSoup
URL='https://mel73157.site/live/mortal-kombat/1252965-mortal-kombat-x/'
HEADERS= {'user-agent':'Mozilla / 5.0 (Windows NT 10.0; WOW64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 80.0.3987.132 YaBrowser / 20.3.2.242 Yowser / 2.5 Safari / 537.36'}
def get_html (url, params=None):
r = requests.get(url,headers=HEADERS, params = params)
return r
def get_content(html):
soup= BeautifulSoup(html,'html.parser')
items= soup.find_all('div', class_='centerCon fl')
player=[]
for item in items:
player.append({
'title': item.find('div', class_='date').get_text(),
})
print(player)
def parse():
html = get_html(URL)
if html.ok:
get_content(html.text)
else:
print('Ошибка в запросе')
parse()
Answer the question
In order to leave comments, you need to log in
As I understand it, the URL page should still be opened by a regular browser. It doesn't open for me. Maybe that's why the error?
You try instead your mortalkombat to start opening a little easier.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question