B
B
budro2020-12-18 11:09:53
Wget
budro, 2020-12-18 11:09:53

Python wget xml?

I'm trying to download an xml file (TV program) wget :
wget.download(" epg.it999.ru/epg2.xml.gz ", "epg.xml")

As a result, I get this mess:
‹ ¬S[sЗ•5ъ|&в‡ 'zhxB‡RWU_g<yuўq%D ҃Ґ "PКltslD0OEYІ'¤П'hЭ†&%Rte& ? ePPzOHџkhyuZO~ьMMttye•Yo°зџцћ]tћE.yug/

How to fix?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2020-12-18
@budro

Because .gz is an archive, so it needs to be unpacked. And yes, the wget library is not very common, it's better to use requests

A
AlexBoss, 2020-12-18
@AlexBoss

An example of downloading a file using requests. You can download any.

import requests

url = 'https://www.cs.uky.edu/~keen/115/Haltermanpythonbook.pdf'

r = requests.get(url, stream = True)

with open("PythonBook.pdf", "wb") as Pypdf:

  for chunk in r.iter_content(chunk_size = 1024):

    if chunk:

      Pypdf.write(chunk)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question