tasks:
- uri:
url: http://www.example.com/
return_content: yes
register: ex
failed_when: "'Example Domain' not in ex.content"
- debug: var=ex
- set_fact:
links1: "{{ ex.content | regex_findall('<a[^>]+>', multiline=True, ignorecase=True) }}"
- debug: var=links1
- set_fact:
links2: "{{ links2 | default([]) + [item | regex_replace('.*href=','', ignorecase=True) | regex_replace('[\\s>]+.*','') | regex_replace('[\"]','') | regex_replace(\"'\",'')] }}"
loop: "{{ links1 }}"
- debug: var=links2