I am just trying to get the current absolute url of the page. Here is the snippet of the code
my $url_str = "BEFORE";
$sel->storeLocation("url_str");
$sel->comment(URL is $url);
Send command: storeLocation|url_str|
Got result : OK
Comment : URL is BEFORE
It does not seem to work. I tried with $url_str, \$url_str as arguments to the storeLocation but in vain. Please help on what exactly am I missing here
The Perl API uses the more Perlish 'get_' as a prefix instead of the Selenium standard of 'store'. Also the Perl API uses underscores instead of camel case.
# returns the current url
$sel->get_location()
Also see:
The WWW::Selenium docs on CPAN
The Test::WWW::Selenium docs on CPAN
The official Selenium docs
Related
I am using the following query:
https://api.github.com/search/repositories?q=mysql&created:%3C2009-04-11&order=asc
and see the same results as:
https://api.github.com/search/repositories?q=mysql&created:%3E=2013-04-11&order=asc
Looks the created is not taking into effect.
can you please help me if I am missing anything in the query?
At document of REST API v3, parameters are added using +. So how about the following modification?
From :
https://api.github.com/search/repositories?q=mysql&created:<2009-04-11&order=asc
https://api.github.com/search/repositories?q=mysql&created:>=2013-04-11&order=asc
To :
https://api.github.com/search/repositories?q=mysql+created:<2009-04-11&order=asc
https://api.github.com/search/repositories?q=mysql+created:>=2013-04-11&order=asc
If I misunderstand your question, I'm sorry.
Edit :
When you want to retrieve the data using curl, please use as follows. In this case, please enclose the URL using double quotations. The URL in this sample is from your comments.
curl "https://api.github.com/search/repositories?q=python+created:%3E2009-04-11&page=1"
or
curl "https://api.github.com/search/repositories?q=python+created:>2009-04-11&page=1"
I've just figured out how to complete a Nutch crawl via the REST api for the 2.3 version of Nutch. You can see my post here. So after running the crawl, I go to MongoVue to check out the results and there is no "status" or "baseUrl" fields, along with others. Now if I do a normal crawl through cygwin, I get all fields. Is there some parameter I'm missing from the POST request to UPDATEDB call?
Here is the last call I make for Updatedb.
{
"args":{
"crawlId":"crawl-01",
"batch":"1428526896161-4430"
},
"confId":"default",
"crawlId":"crawl-01",
"type":"UPDATEDB"
}
I figured it out. The timestamp used in the GenerateJob step was wrong. It needed to be in a particular format and my code wasn't supporting it. Found a work around.
I am trying to use HTTP to POST a file to an outside API from within a grails service. I've installed the rest plugin and I'm using code like the following:
def theFile = new File("/tmp/blah.txt")
def postBody = [myFile: theFile, foo:'bar']
withHttp(uri: "http://picard:8080/breeze/project/acceptFile") {
def html = post(body: postBody, requestContentType: URLENC)
}
The post works, however, the 'myFile' param appears to be a string rather than an actual file. I have not had any success trying to google for things like "how to post a file in grails" since most of the results end up dealing with handling an uploaded file from a form.
I think I'm using the right requestContentType, but I might have missed something in the documentation.
POSTing a file is not as simple as what you have included in your question (sadly). Also, it depends on what the API you are calling is expecting, e.g. some API expect files as base64 encoded text, while others accept them as mime-multipart.
Since you are using the rest plugin, as far as I can recall it uses the Apache HttpClient, I think this link should provide enough info to get you started (assuming you are dealing with mime-multipart). It shouldn't be too hard to change it around to work with your API and perhaps make it a bit 'groovy-ier'
I am using Mason 1.0 and want to redirect the page to another URL.
Is there any way to redirect?
Alternatively...
I have written following code in dbhandler which is giving error, stating that $r is undefined. Can you please help.
$r->method('GET');
$r->headers_in->unset('Content-length');
$r->content_type('text/html');
$r->header_out('Location' => $newPageURL);
$m->abort(301);
I cannot use $m->redirect as it is not avalible to me.
I am referring to this link http://www.masonhq.com/htmlmason/wiki/FAQ:HTTPAndHTML on the section "How do I do an external redirect?"
$r->status(302);
$r->headers_out()->add("Location", "http://google.com");
return 302;
Looks like $m->clear_buffer is missing before your first call.
It's required so it wipes out any response generated before you reach your redirection.
I want to fill in a web form with Perl. I am having trouble finding out the correct syntax to accomplish this. As in, how do I go to the URL, select the form, fill in the form, and then press enter to be sure it has been submitted?
Something like WWW::Mechanize::FormFiller?
WWW::Mechanize and its friends are the way to go. There are several examples in Spidering Hacks, but you'll also find plenty more by googling for the module name.
Good luck, :)
Start with WWW::Mechanize::Shell:
perl -MWWW::Mechanize::Shell -e shell
get http://some/page
fillout
...
submit
Afterwards, type "script", and save generated code as something.pl - and that's about it. It's done.
Request the form's action URL with Net::HTTP or something (can't recall the exact module), and include the forms fields as a GET/POST parameter (whichever the form calls for).
HTML::Form works nicely, too.
The synopsis of the module is an excellent example:
use HTML::Form;
$form = HTML::Form->parse($html, $base_uri);
$form->value(query => "Perl");
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$response = $ua->request($form->click);