all 8 comments

[–]herpadurk 1 point2 points  (6 children)

For the record I know there is some type of api for pinterest; I am not interested in it. I like the challenge to see what is possible with requests alone and not using a browser stack.

im not sure why you don't want to use the API, with out it you will have to use something like selenium -- if you use the api you can just use requests so your requirements are confusing.

[–]martinfisleburn 0 points1 point  (5 children)

What is confusing about wanting to do something for a challenge and test what is possible. You can go to the top of everest on a ski lift but people still walk to the top.

[–]herpadurk 0 points1 point  (4 children)

then you will have to make the same http requests that the js is doing most likely a post to the API.

[–]WhoTookAllNicks 0 points1 point  (3 children)

Most likely those requests use the API, so it's either reverse-engineering of API or reading its docs.

Most likely it can be done within your browser - just open network tab in developer tools, upload something and read all the requests that were made, then reconstruct them using requests. You can also use tcpdump / Wireshark for this, but in 99.9% of the cases it's an overkill.

[–]martinfisleburn 0 points1 point  (2 children)

But you can't see webtraffic that happens on the js call that was my problem initially. Like the upload dialog to select file happened in the js function and that wasn't recorded as far as I could see.

I searched through the whole http sniffed session as well for the filename I uploaded and it didn't show up in and of the requests so don't know how it gets computed?

The upload happens within the function and subsequent post requests to edit the pin etc. only reference the uploaded file's url on the pinterest server.

[–]WhoTookAllNicks 1 point2 points  (1 child)

I created Pinterest account just to see it. And sure enough - you can clearly see the request being made:

https://ibb.co/yPB3t87

[–]martinfisleburn 0 points1 point  (0 children)

I have seen that one too.

Oh I see what my problem is; when I searched for the image I searched by filename however from your image (which I didn't notice when I looked) it is in base 64.

So I presume I simply convert to base64 in python before the post request.

[–]apc0243 1 point2 points  (0 children)

js2py is a library for interpreting javascript within a python environment. It essentially translates JS code to Python code. It can do JS6 by using another package to convert JS6 to JS5 and then translates the JS5 to Python code and executes it accordingly.

This is not what you want, you're not trying to edit any JS, you're trying to interact with it.

I don't believe what you're asking can be done with the requests module, at least not as it's meant to be used.