[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use variable from BEGIN as input to remaining program

From: Z
Subject: Re: Use variable from BEGIN as input to remaining program
Date: Wed, 06 Sep 2023 21:34:29 +0000
User-agent: mail v14.9.24

port19 <> wrote:

> Hi all,
> I have now managed to send https requests via the use of stunnel.
> My current problem is that it seems impossible to reuse the response.
> In my limited research I did not manage to find ways to define records in 
> Is it possible to use output retrieved in BEGIN as input for the rest of the 
> program?
> If yes, how so? If not, how would you proceed?
> Context is the rewrite of a small reddit client. [1]
> ~port19
> [1]

This seems to sort of do what you want; I used your stunnel.conf settings and
simplified redqu.awk some for testing purposes (just extracts i.redd.t/*.jpg):

#!/usr/bin/gawk -E
  subreddit = "cats"
  sort = "/top.rss"
  time = "?t=hour"
  endpoint = "/r/" subreddit sort time

  print endpoint

  target = "/inet/tcp/0/localhost/111"
  agent = "Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 
  payload = "GET " endpoint " HTTP/1.1" "\r\n" "Host:" 
"\r\n" "User-Agent: gawk" "\r\n" "Connection:close" "\r\n\r\n"

  print payload |& target

  while ((target |& getline line) > 0)
    response = response " " line


  for (i in array)
    if (array[i] ~ /i[.]redd[.]it[/][a-z0-9]*[.](png|jpg|gif)?/)
      print array[i]

# test run:
$ redqu.awk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]