0
  • I am trying to extract from the URL
  • I am trying to get the download from the first URL which file_type file_type is DLTINS

Below is the code

import requests
import xml.etree.ElementTree as ET
response = requests.get("https://registers.esma.europa.eu/solr/esma_registers_firds_files/select?q=*&fq=publication_date:%5B2021-01-17T00:00:00Z+TO+2021-01-19T23:59:59Z%5D&wt=xml&indent=true&start=0&rows=100")
root = ET.fromstring(response.text)

I am getting like object <xml.etree.ElementTree.ElementTree at 0x7fd745e84da0>

In response.text I am getting everything in string

2
  • share the xml so we can have a look. share your code as well Commented Aug 18, 2021 at 17:06
  • I'm not sure what the problem is. You got an ElementTree object--that's what you want isn't it? Commented Aug 18, 2021 at 17:08

1 Answer 1

1

Here is the solution

import requests
import xml.etree.ElementTree as ET


response = requests.get('https://registers.esma.europa.eu/solr/esma_registers_firds_files/select?q=*&fq=publication_date:%5B2021-01-17T00:00:00Z+TO+2021-01-19T23:59:59Z%5D&wt=xml&indent=true&start=0&rows=100')
root = ET.fromstring(response.text)
for i in root.findall('result'):
    for j in i.findall('doc'):
        for k in j:
            link = j.find('.//str[@name="download_link"]').text
            print(link)
            req = requests.get(link)
Sign up to request clarification or add additional context in comments.

2 Comments

The zip file is not downloading
got it I should be doing open('dfd.zip', 'wb').write(req.content)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.