25 lines
557 B
Python
25 lines
557 B
Python
|
import csv
|
||
|
from beakers.recipe import Recipe
|
||
|
from beakers.beaker import Beaker
|
||
|
|
||
|
urls = Beaker("urls")
|
||
|
responses = Beaker("responses")
|
||
|
|
||
|
|
||
|
async def add_response(obj_with_url):
|
||
|
url = obj_with_url["url"]
|
||
|
response = await httpx.get(url)
|
||
|
return {
|
||
|
"url": url,
|
||
|
"status_code": response.status_code,
|
||
|
"response_body": response.text,
|
||
|
}
|
||
|
|
||
|
|
||
|
agencies = Beaker.from_csv("agencies", "agencies.csv")
|
||
|
responses = Beaker("responses")
|
||
|
recipe = Recipe("fetch urls")
|
||
|
recipe.add_pour(agencies, responses, add_response)
|
||
|
|
||
|
recipe.run_linearly()
|