in reply to Re: problem with german chars in html post fetch
in thread problem with german chars in html post fetch
I did the convert ansi->oem for my script file before running it, and ran it again, but this time neither of the save attempts retrieved any suggestions from the google tool.
You can see for yourself, assuming the perlmonks code grepper works for these weird characters.
Thanks anyway though!# adwordsDebugGermanOem.pl use strict; use HTTP::Request::Common; # HTTP handling use LWP::UserAgent; # HTTP handling my $query = 'brse'; my $www; #doesn't work. #sends $query = 'brse'; $www = google_keyword_suggestions_html_debug('de', 'de', $query); open F, "> doesntwork.html" or die "Cannot open."; print F $www->content,"\n"; close F; #works -- keyword suggestions are retrieved #sends $query = 'brse'; #keyword suggestions are retrieved, although the html is kind of warpe +d looking. $query = germanchars_to_strange_html_chars($query); $www = google_keyword_suggestions_html_debug('de', 'de', $query); open F, "> works.html" or die "Cannot open."; print F $www->content,"\n"; close F; # returns $www object containing html for a successful code, or an err +or code sub google_keyword_suggestions_html_debug { my $language = shift; my $country = shift; my $query = shift; #this could be a list, but leaving it as a sing +le word. maybe change later. my $action = POST 'https://adwords.google.com/select/KeywordSandbox', [ 'save' => "save", 'wizard_name' => "keywordsandbox_wizard", 'language' => $language, 'country' => $country, 'keywords' => $query, ]; my $ua = LWP::UserAgent->new; $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); $ua->timeout(30); my $www = $ua->request( $action ); return $www; } # Takes a variable and spits it back out with the proper german charac +ters sub germanchars_to_strange_html_chars { my $var = shift; my %table = ( '' => 'Y', '' => '', '' => '', '' => '', '' => '', '' => 'Ǭ', '' => 'Ǭ'); while (my ($k,$v) = each %table) { $var =~ s/$k/$v/g; } return $var; }
Any other ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Not this time.
by holli (Abbot) on Jan 07, 2005 at 22:06 UTC | |
|