I have decided to try my hand at python for the first time to develop a simple web scraper. Nothing too intense. However, I can't seem to get past the header part.
Here is a snippet of the code that keeps throwing an error:
SESSIONID = "25629049223%3AcMInr0QniTUttj%3A17%3AAYela4VVJtCpP5d1Wy1wnmE5nz4II28IAKWmpF-hlQ"
headers = {
"data": {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36",
"cookie": "sessionid=(SESSIONID)"
}
}
When I run the program, I get this error:
requests.exceptions.InvalidHeader: Header part ({'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36', 'cookie': 'sessionid=(SESSIONID)'}) from {'data': {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36', 'cookie': 'sessionid=(SESSIONID)'}} must be of type str or bytes, not <class 'dict'>
I've tried messing around with the format of the code including adding str() around the values and/or keys in various ways but I still continue to get the error.
It's clear to me that it needs to be a string. But when I change the format, I either get the same error, end up accidentally changing it to a 'list', or break it in some other way. I think at this point my lack of knowledge is getting the best of me.
Any advice would be much appreciated!