By default, the search term is passed to the results web part through the URL query string parameter, e.g. ?searchtext=searchTerm
. So, you can use query string macros and read this value, just be careful for SQLi and security. For example, three different ways of achieving the same:
1. {%searchtext%}
2. {%QueryString.searchtext%}
3. {%QueryString["parameter"]%}