F
F
flashdix2019-04-17 09:42:22
Python
flashdix, 2019-04-17 09:42:22

How to parse json-ld object without downloading the whole page?

Welcome all. There is the following code.

import extruct
import requests
import pprint
from w3lib.html import get_base_url
pp = pprint.PrettyPrinter(indent=2)
r = requests.get('https://avtoinstrument.kz/p58052466-podemnik-dvuhstoechnyj-380v.html')
base_url = get_base_url(r.text, r.url)
data = extruct.extract(r.text, base_url=base_url)
pp.pprint(data)

Question:
Is it possible to somehow stop the download after receiving the json-ld object so as not to download the entire source code of the page?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question