sparklemotion / mechanize

Mechanize is a ruby library that makes automated web interaction easy.
https://www.rubydoc.info/gems/mechanize/
MIT License
4.39k stars 473 forks source link

[Documentation] More examples? Specifically for imgur + ruby. #641

Closed rubyFeedback closed 4 months ago

rubyFeedback commented 4 months ago

Hey guys,

Some examples can be found here:

https://github.com/sparklemotion/mechanize/blob/main/EXAMPLES.rdoc

First, there are only like 5 examples or so. Perhaps more could be added; that can include small use cases too, FAQ-ish elements (or perhaps move them into the FAQ).

Anyway, now to the gist of this.

Imgur changed its API some time ago and in the process broke a ruby script I was using to upload things to imgur from the commandline. I don't understand the changed format and I have no interest in creating an account when before we did not need this. I assume we can still upload in an automated way as the formular still works and I can manually upload things, but I don't understand the code or changes they use.

So I was thinking I could use mechanize to do so. But I have no real idea how to do so and I can not afford investing several hours into learning mechanize properly (sorry about that, I am aware it is a problem, but the time constraints make it impossible for me to invest too much time into projects usually).

I was thus hoping for a ready-made SMALL example how to use mechanize with regard to imgur. Or, if that is too specific, a tiny mini-tutorial that explains how to go about this; I know HTML and CSS, at the least somewhat well, but I don't really know how to adjust mechanize towards being able to create a commandline script for uploading images to imgur as-is.

If someone knows how to do so, perhaps another example can be added, a minimal imgur example. I really only need the very bare minimum:

1) local image exists, /tmp/foobar.png 2) the code for mechanize how to upload it

I assume it may be trivial, e. g. if we have the input-field, we assign it to the local file, e. g. the path of foobar.png and then submitting this, and then getting back the new HTML page (at the least the URL for the new HTML page at imgur).

Anyway, thank you for reading this; hopefully in the long run more examples and more FAQ entries could be added to mechanize. It seems like a really nifty library as it is.