Tonyd5915 has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that the cookie values for the URL aren't being set properly. I then use the cookie data for a follow-up HTTP request. The URL works if I don't use variables and hard-code the values for Month and Year, but it doesn't work when I use the variables Month=$month and Year=$year. The variable is $url_to_get. It works when I put the values in for Month and Year:$month = "1" $year = "2013"
but this doesn't work:$url_to_get = 'http://tennislink.usta.com/Tournaments/Schedule/SearchR +esults.aspx?Action=2&Month=1&Year=2013&Sanctioned=0&SearchRadius=-1&E +ntryLevel=False&Intermediate=False&Advanced=False';
This is a portion of my script: (some of the modules are for other parts of the script)$url_to_get = 'http://tennislink.usta.com/Tournaments/Schedule/SearchR +esults.aspx?Action=2&Month=$month&Year=$year&Sanctioned=0&SearchRadiu +s=-1&EntryLevel=False&Intermediate=False&Advanced=False';
This is what gets written to the cookie file:#!/usr/bin/perl use URI::URL; use LWP::UserAgent; use HTTP::Request; use HTTP::Headers; use HTTP::Response; use HTTP::Cookies; use WWW::Mechanize; $month = "3"; $year = "2014"; $url_to_get = 'http://tennislink.usta.com/Tournaments/Schedule/SearchR +esults.aspx?Action=2&Month=$month&Year=$year&Sanctioned=0&SearchRadiu +s=-1&EntryLevel=False&Intermediate=False&Advanced=False'; $ua = LWP::UserAgent->new; $ua->agent('Mozilla/4.0 (Compatable; MSIE 5.01; Windows NT 5.0)'); $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave +=> 1)); $res = $ua->request(HTTP::Request->new(GET => "$url_to_get")); $content = $res->as_string( ); @content = split ("\n", $content); foreach $info (@content) { if ($info =~ "Displaying 1 ") { print "$info\n"; } }
You can see that the Month and Year values in the tennislink.usta.com cookie are set to zero. (The values for $month and $year are normally entered on the command line).cat lwp* #LWP-Cookies-1.0 Set-Cookie3: BigIPCookie=3658774282.20480.0000; path="/"; domain=tenni +slink.usta.com; path_spec; expires="2013-12-12 23:07:09Z"; version=0 Set-Cookie3: tennislink.usta.com_Search="Action=2&Keyword=&TournamentI +D=&SectionDistrict=&City=&State=&Zip=&Month=0&Day=&Year=0&Division=&C +ategory=&Surface=&OnlineEntry=0&DrawsSheets=0&PageNum=0&UserTime=&San +ctioned=0&AgeGroup=&SkillLevel_EntryLevel=False&SkillLevel_Intermedia +te=False&SkillLevel_Advanced=False&SearchRadius=-1&QuickSearch=0&Orde +rBy=3"; path="/"; domain=tennislink.usta.com; path_spec; expires="201 +4-06-12 18:07:08Z"; version=0
Any assistance will be greatly appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTTP::Request -Variable values not translating in URL
by toolic (Bishop) on Dec 12, 2013 at 19:03 UTC | |
by Tonyd5915 (Initiate) on Dec 12, 2013 at 19:22 UTC | |
by Tonyd5915 (Initiate) on Dec 12, 2013 at 19:33 UTC | |
|
Re: HTTP::Request -Variable values not translating in URL
by PerlSufi (Friar) on Dec 12, 2013 at 21:08 UTC | |
by Tonyd5915 (Initiate) on Dec 12, 2013 at 22:28 UTC | |
by Anonymous Monk on Dec 13, 2013 at 02:55 UTC | |
|
Re: HTTP::Request -Variable values not translating in URL
by taint (Chaplain) on Dec 12, 2013 at 21:00 UTC |