I am trying to fetch the cookies of a website and then work with them, through the Python extension in KNIME.
If I execute the code inside the node, I get to see the cookie the way I want to, and there are no errors.
If I execute the node, trying to work with the output on a different node, I get the following error:
“Execute failed: Expected pandas.DataFrame, got <class ‘request.cookies.RequestCookieJar’> Please make sure your output_table is a pandas.DataFrame.”
So I investigated a bit deeper and it seems that for every Python node running, it is necessary to declare an “output table” (“output_table”), but not sure how to do so successfully.
Here’s my small code
import requests
from pandas import DataFrame
import pandas as pd
from pandas import DataFrame
import requests
session = requests.Session()
x = session.get( flow_variables['URL'])
res = session.cookies.get_dict()
output_table = DataFrame({'cookies':res})
In summary, KNIME is happy to receive a JSON structure as data for the output table. Nicely, it generates in this way a table with the names of the cookies as index of the table rows:
This is awesome, it really does help. Sorry I couldn’t reply earlier. I will start playing around with that table it creates for the export since it covers my needs for the export of the python node, but not entirely fits what I need for an import of a different node (a single string containing the whole cookie), but I guess this would be much easier. Again, thank you for your helpful response.