# Using get\_url or uri - substitute for curl?

**URL:** <https://forum.ansible.com/t/using-get-url-or-uri-substitute-for-curl/33042>\
**Category:** AWX Project\
**Created:** [May 28, 2020, 6:34pm UTC](https://forum.ansible.com/t/using-get-url-or-uri-substitute-for-curl/33042 "2020-05-28T18:34:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_Biker](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bill_biker/32/8087_2.png) [@Bill\_Biker](https://forum.ansible.com/u/Bill_Biker)\
**Post date:** [May 28, 2020, 6:34pm UTC](https://forum.ansible.com/t/using-get-url-or-uri-substitute-for-curl/33042/1 "2020-05-28T18:34:20Z")

</div>

Hello,  
I have been searching for a way to use ansible to find a file on a remote host that is accessible via http.  
I have a bash script that uses curl to connect to the http addr, and look for a \*.iso file.  
If it finds the file, it breaks it up using awk, etc to get the file info. the file is named  
errata-20200506.iso - i.e. errata is returned, and the date is returned from the file name - but the file is  
not downloaded unless it is newer than a file on the local server. if the iso file is newer, it downloads it  
to the local server.

I would like to find a way to do this with ansible/yaml - I have used get\_url, but I have to specify the file name  
I cannot parse the file for date etc before it downloads, etc.

How can I do this in yaml?

Thanks so much,

ewholz  
Ansible beginner

---

<div class="post-metadata">

**Author:** ![dan\_linder](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dan_linder/32/3833_2.png) [@dan\_linder](https://forum.ansible.com/u/dan_linder)\
**Post date:** [May 29, 2020, 5:33pm UTC](https://forum.ansible.com/t/using-get-url-or-uri-substitute-for-curl/33042/2 "2020-05-29T17:33:49Z")

</div>

With a bit of work, you can use the “uri:” module like this:

```auto
---
- name: Test getting web page
hosts: localhost
gather_facts: false

tasks:
- name: Get web information
uri:
url: https://releases.ansible.com/ansible/
return_content: true
register: web_files

- name: Show just the content
debug:
msg: "Here is the file: {{ web_files.content }}"

- name: Show each element
debug:
msg: "An item: {{ item }}"
loop: "{{ web_files.content.splitlines() }}"
loop_control:
label: ""

```

For your use, the key is the “return\_content: true” flag then parsing it out of the registered “web\_files” variable.

The first task “Show just the content” shows all the raw HTML text returned.

The second task loop over each of those lines - you will have to put in more Jinja2 code to parse out the file names, but this would permit you to do some checks before downloading the much larger ISO.
