Skip to content

Commit

Permalink
Non-minified sitemaps support
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyyakym committed Oct 15, 2020
1 parent 2399da4 commit 15e3b26
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sitemap-urls.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/bash

# $1 - xml url
parse_xml() {
urls=`curl -s $1 | sed -n 's/^.*<loc>\(.*\)<\/loc>.*$/\1/p'`
xmls=(`grep -e ".xml$" <<< $urls`)
xml=`curl -s $1`
locations=$(tr '\n' ' ' <<< "$xml" | grep -oP "(?<=<loc>)(.*?)(?=</loc>)")
sub_xmls=(`grep -e ".xml$" <<< $locations`)
pages=(`grep -v -e ".xml$" <<< $locations`)
for xml_url in "${xmls[@]}"
printf '%s\n' "${pages[@]}" >&1
for xml_url in "${sub_xmls[@]}"
do
parse_xml $xml_url
done
pages=(`grep -v -e ".xml$" <<< $urls`)
printf '%s\n' "${pages[@]}" >&1
}
parse_xml $1

0 comments on commit 15e3b26

Please sign in to comment.