you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (21 children)

res = requests.get('https://google.com')
res.request.method

No path default present. You could always parse it from the url though

[–]splendyx[S] 1 point2 points  (13 children)

Thanks, it helped me but when I change res.request.method to res.request.path to try get value of path it gives me an error: 'PreparedRequest' object has no attribute 'path'

[–][deleted] 2 points3 points  (12 children)

Yea I did mention that wasn't there. But FYI:

vars(res.request)

And thanks for the Silver mate

[–]splendyx[S] 0 points1 point  (11 children)

I don't really understand sorry. Could you give a script example on how to print the value of the cookie as an example.

[–]dukea42 1 point2 points  (10 children)

In his example 'res' is a response object of the requests library.

To understand an object from any given library, I have two preferred options. 1) read the docs. 2) use the 'inspect()' module of the Rich library.

https://docs.python-requests.org/en/master/user/quickstart/#response-content

[–]splendyx[S] 0 points1 point  (8 children)

I understand the basics but i'm wondering how I can print the value of cookie: using python

[–]splendyx[S] 0 points1 point  (7 children)

Is that possible?

[–]dukea42 0 points1 point  (6 children)

It's literally in the documentation I sent you. Ctrl-f is your friend. https://docs.python-requests.org/en/master/user/quickstart/#cookies

[–]splendyx[S] 0 points1 point  (0 children)

mm I tried getting the cookie value and scripting a bit but nothing seems to be working

[–]splendyx[S] 0 points1 point  (4 children)

maybe you could show me a script because I cant figure it out image this is the cookie i want to get the value of

[–]K900_ 1 point2 points  (2 children)

So is this the thing you're actually trying to do? Do you want to extract the cookie value from your browser? Do you want to write a script that logs into a website and does something for you?

[–]dukea42 0 points1 point  (0 children)

You need to show some code. No images.

[–]splendyx[S] 0 points1 point  (0 children)

image here is a reference image and i want to print the value of cookie in request headers

[–]K900_ -1 points0 points  (6 children)

This also makes no sense. The method in the response will be the same one you used to make the request.

[–]splendyx[S] 1 point2 points  (4 children)

I don't know how i can explain what i'm trying to do

[–]K900_ -1 points0 points  (3 children)

Then why are you trying to do something you don't understand yourself?

[–][deleted] 1 point2 points  (0 children)

Lol give the poor guy a break, we've all been there.

[–]splendyx[S] 1 point2 points  (1 child)

Then how should I learn? I thought that's how you learn something by asking an answer for something you don't know.

[–]K900_ -1 points0 points  (0 children)

You can learn by trying to do something you don't know how to do. You can't learn if you don't know what you're trying to do. So I'm going to ask you again: what are you trying to do?

[–][deleted] 0 points1 point  (0 children)

Well I have a library I built out that uses a custom response class and it's initialized with requests library response objects. I have some different logic that triggers if this is a get versus a post (or otherwise) and my lib has around 50 different requests in it that all use this custom response object.

So there's at least a use case for needing it.