in reply to running an example script with WWW::Mechanize* module
WWW::Mechanize::Chrome doesn't inherit from WWW::Mechanize, but it strives to provide the same API as WWW::Mechanize where possible/applicable.
In some situations, I've deviated from the WWW::Mechanize API unfortunately, instead of either using a different method name or expanding the API in a compatible way...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: running an example script with WWW::Mechanize* module
by Aldebaran (Curate) on Apr 19, 2020 at 01:25 UTC | |
Okay, and this because you don't have this in WMC: use base qw(WWW::Mechanize);right? I have to wonder if you considered other namespaces to put this, in particular when I found out that WWW::Mechanize inherits from LWP::UserAgent: In some situations, I've deviated from the WWW::Mechanize API unfortunately, instead of either using a different method name or expanding the API in a compatible way... From all of this background reading of what happened over the last 20 years of the internet and perl, the idea that one would want to faithfully represent in every detail what worked in 2003 with what works in 2015 seems like folly. I'll try out the new stuff and see how I do with it. I hauled out one of my favorite WMG scripts only to find that it doesn't populate values correctly anymore, so I'm ready to start using newer tools. I have achieved such a minor amount of success. Between readmore tags I'll post the older script that I'm trying to modernize: Read more... (4 kB)
I'm fairly confident that it behaved and produced accurate results. (There is a chance that it was a script that I was trying to extend and lost my way. I can't always tell them apart.) Now let's look at how far I've gotten with WMC:
Terminal output:
The log output shows that I've been jimmying with the loop values that I'm using to figure out which form I need. It turns out, it is not zero-based in this context. Zero bombs out.
Whilst far short of a grand opus or masterpiece, this script does something that I couldn't manage with WM, namely, effective logging. Log::Log4Perl is required on WMC, which has the advantage of that functionality. The disadvantage is that you've gotta get it installed, which has been a (fixable) problem for some. It didn't want to install with my strawberry perl on windows 10, which I house on another partition. Two ways to solve the problem are given in getting Log::Log4perl to install on windows strawberry perl. So, where am I stuck? Well, this is hot off the press and represents several similar attempts. It's nice to be using WMC and log4perl to figure this out. You can't be reading the same things the machines do as it overwhelms STDOUT. My partial results are encouraging, and this seems very much like a problem of getting forms and fields set and selected with new methods calls. Here is the uri we're looking at. It's a fun site, and you can readily enter your own information. I do have data from the formdump:
Fishing for tips. Thanks, Corion for your response and this considerable achievement:
| [reply] [d/l] [select] |
by Corion (Patriarch) on Apr 19, 2020 at 06:28 UTC | |
There is a misunderstanding of $mech->success - this method only reflects whether the last HTTP response from the server is considered an error or not. It does not reflect whether the last operation on $mech was successful or not. Error checking is usually done by die by WWW::Mechanize::Chrome. I haven't run your code, but the log output suggests that the form you're looking at has no name:
The form is not great, because it really contains three fields with the same name date, so you will have to fetch the individual fields and explicitly set them:
In the next version, I'll actually implement the arrayref form of ->set_fields() for values of index larger than one :) But that means breaking my (incompatible) API to restore the WWW::Mechanize API so I'll have to look carefully there.
| [reply] [d/l] [select] |
by Aldebaran (Curate) on Apr 21, 2020 at 03:22 UTC | |
Thanks, Corion, I think we're almost there. I've got this pared down as far as I can to make an SSCCE. I can't get perl to think I have a valid selector:
Source, with the critical line tried several different ways:
That lays it out there as starkly as I can. VielenDank und Gruss aus Amiland. | [reply] [d/l] [select] |
by Corion (Patriarch) on Apr 21, 2020 at 06:07 UTC |