Y
Y
YeaNot2021-07-05 16:04:24
Python
YeaNot, 2021-07-05 16:04:24

Why doesn't the parser return anything?

You need to parse the cost of a product on its Ozon page, but nothing is retrieved from it at all:

request = requests.get('https://www.ozon.ru/product/holodilnik-indesit-tia-180-belyy-277079362/', HEADERS)
page = BeautifulSoup(request.content, 'lxml')
print(page)


Why? And what to do in such a situation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bl4ckm45k, 2021-07-07
@Bl4ckm45k

Add 'User-Agent' key to headers
For example
'User-Agent': 'PostmanRuntime/7.28.1'

Code Example
import requests
from bs4 import BeautifulSoup
import lxml
url = "https://www.ozon.ru/product/holodilnik-indesit-tia-180-belyy-277079362/"

payload = {}
headers = {
    'User-Agent': 'PostmanRuntime/7.28.1',
    'Cookie': 'ЗДЕСЬ КУКИ'}

response = requests.request("GET", url, headers=headers, data=payload)

page = BeautifulSoup(response.content, 'lxml')
print(page)

found the price only in this item
spoiler
<div id="state-webPrice-836055-default-1"
          data-state='{"isAvailable":true,"price":"17 990 ₽","originalPrice":"20 390 ₽","showOriginalPrice":true,"mode":"credit","payment":"1 799 ₽","paymentTerm":"12 мес","hintLink":"https:\u002F\u002Fwww.ozon.ru\u002Fsection\u002Fcredit\u002F","hintText":"Приблизительный расчет. Платеж зависит от срока и типа кредитного продукта"}'>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question