summaryrefslogtreecommitdiff
path: root/contrib/wikipedia-search-handler
blob: 72f051fcf8bab5245e61280de807f026d0082847 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash
uri="$1"
shortened="$(unshorten.sh "${uri}")"
if [ "${shortened}" ];then
  uri="${shortened}"
fi
shortened="$(unshorten.sh "${uri}")"
if [ "${shortened}" ];then
  uri="${shortened}"
  uristart "$uri"
else
  curl -g "$uri" | grep '^<i>The page "<a href="/w/index' | sed 's|<i>\([^<]\)</i>||g' | tr '<' '\n' \
    | grep ^a \
    | cut '-d"' -f2 \
    | sed 's|^/|https://en.wikipedia.org/|g' \
    | text_uri-list
fi