Skip to content

Commit 01d5f47

Browse files
author
Raphaël Droz
committedNov 19, 2018
maxlengths
1 parent b294959 commit 01d5f47

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
 

‎_gen-maxlength.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# cookie="60gpD=xxx; PHPSESSID=xxx"
4+
5+
[[ -z $cookie ]] && exit 1
6+
7+
urlencode() {
8+
python3 -c 'import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]));' "$1"
9+
}
10+
11+
jq -r '.[]|.' < postalcodes.json | \
12+
grep -F ^ | \
13+
sed -r -e 's/\{([0-9])\}/{\1,\1}/g' -e 's/\^|\$/\//g' -e 's/\\([()])/\1/g' | \
14+
sort -u | \
15+
while read -r f; do
16+
g=$(urlencode "$f");
17+
echo "$f";
18+
curl -s 'https://www.dcode.fr/api/' \
19+
-H 'User-Agent: Mozilla/5.0' \
20+
-H 'Accept: application/json, text/javascript, */*;' \
21+
-H 'Referer: https://www.dcode.fr/regular-expression-analyser' \
22+
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
23+
-H 'X-Requested-With: XMLHttpRequest' \
24+
-H 'Cookie: $cookie' \
25+
-H 'TE: Trailers' \
26+
--data "tool=regular-expression-analyser&regexp=$g&max_length=true" | \
27+
jq -r .results;
28+
sleep 1;
29+
done

‎maxlength.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
10
2+
# Current maximum postal code size is 10
3+
# Countries: US, AS, IR

0 commit comments

Comments
 (0)
Please sign in to comment.