Home AMX User Forum AMX General Discussion
Options

Weather Underground and HTTP/1.1 301 Moved Permanently

So I've been using weather underground for weather lately and has been pretty nice.
A couple of months I received the above error. They had went to HTTPS from HTTP.
So after some research I found that adding :443 to the end of my host command got everything working again.
A few days ago the error is back and I am stumped!
I send:

SEND_STRING dvCheckWeather, "'GET /cgi-bin/findweather/getForecast?query=60110 HTTP/1.1',13,10"
SEND_STRING dvCheckWeather, "'Host: www.wunderground.com:443',13,10"
SEND_STRING dvCheckWeather, "'Authorization: Basic',13,10"
SEND_STRING dvCheckWeather, "'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.5',13,10"
SEND_STRING dvCheckWeather, "13,10"

and get this:

HTTP/1.1 301 Moved Permanently
Server: Apache/2.2.15 (CentOS)
Pragma: no-cache
Location: https://www.wunderground.com/cgi-bin/findweather/getForecast?query=60110
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 87
Content-Type: text/html
Cache-Control: private, no-cache
Expires: Wed, 04 May 2016 17:15:53 GMT
Date: Wed, 04 May 2016 17:15:53 GMT
Connection: keep-alive
Property-id: drupal-prod
X-RequestSource: AkamaiProdProxy
X-RequestSource: AkamaiDefaultDNA

What am I missing???

Comments

  • Options
    ericmedleyericmedley Posts: 4,177
    I just put the two strings on top of each other. The one referenced in the error return is on top.

    https://www.wunderground.com/cgi-bin/findweather/getForecast?query=60110
    https://www.wunderground.com/cgi-bin/findweather/getForecast?query=60110 HTTP/1.1'


    I'd say take off the " HTTP/1.1" at the end of yours and see what happens.
    e
  • Options
    itismyworlditismyworld Posts: 68
    Thanks Eric. No go. I get:

    HTTP/1.0 400 Bad Request
    Server: AkamaiGHost
    Mime-Version: 1.0
    Content-Type: text/html
    Content-Length: 216
    Expires: Wed, 04 May 2016 21:02:39 GMT
    Date: Wed, 04 May 2016 21:02:39 GMT
    Connection: close

    <HTML><HEAD>
    <TITLE>Bad Request</TITLE>
    </HEAD><BODY>
    <H1>Bad Request</H1>
    Your browser sent a request that this server could not understand.<P>
    Reference #7.d7a04968.1462395759.0
    </BODY>
    </HTML>



  • Options
    ericmedleyericmedley Posts: 4,177
    Can you post the code change you made? When I put the link in a browser it seems to work fine. Perhaps it's a glitch in the code.
  • Options
    itismyworlditismyworld Posts: 68
    ONLINE:
    {
    SEND_STRING dvCheckWeather, "'GET /cgi-bin/findweather/getForecast?query=60110',13,10"
    SEND_STRING dvCheckWeather, "'Host: www.wunderground.com:443',13,10"
    SEND_STRING dvCheckWeather, "'Authorization: Basic',13,10"
    SEND_STRING dvCheckWeather, "'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.5',13,10"
    SEND_STRING dvCheckWeather, "13,10"
    }
  • Options
    ericmedleyericmedley Posts: 4,177
    Hmmm... Nothing I see seems out of whack. This may be one of those cases where you might want to Wire Shark the PC and tweak the footer info. Perhaps it doesn't like the stuff after the cgi link.
  • Options
    itismyworlditismyworld Posts: 68
    It is bizarre. I will play around and post back...
    Thanks!
  • Options
    pdabrowskipdabrowski Posts: 184
    Am I right in assuming that module is scraping the public webpage? If so, it may not be returning the correct info as the webpage format has changed.

    Using wunderground might be easier using their direct API that uses HTTP and returns json or XML and the basic info (location lookup, current conditions and 3 day forecast) is free.
    https://www.wunderground.com/weather/api/d/docs
  • Options
    ericmedleyericmedley Posts: 4,177
    I wrote a little module that I posted here that uses an RSS feed that works pretty well. It does it by zipcode. There's a TP template to pull what you need for your UI. Or you can just peek at the code to see how it works.
    http://www.amxforums.com/forum/modpedia-the-public-repository-of-modules-for-everyone/121226-weather-by-zip-code-us-only-from-rss-feed
  • Options
    GregGGregG Posts: 251
    ONLINE:
    {
    SEND_STRING dvCheckWeather, "'GET /cgi-bin/findweather/getForecast?query=60110',13,10"
    SEND_STRING dvCheckWeather, "'Host: www.wunderground.com:443',13,10"
    SEND_STRING dvCheckWeather, "'Authorization: Basic',13,10"
    SEND_STRING dvCheckWeather, "'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.5',13,10"
    SEND_STRING dvCheckWeather, "13,10"
    }


    The host you are specifying has :443 on the end, this leads me to believe you are trying to access the SSL version of the site. That is unlikely to work. The redirect you are getting is their way of telling you they don't want to answer over port 80.

    Also, you are specifying "Authorization: Basic" but not sending any login information, either you don't need that header, or you need to include the proper user/password hashes like "Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l"
  • Options
    itismyworlditismyworld Posts: 68
    Thanks for all your input! I spent hours yesterday trying different things. Still can't get it to work. I am using RSS for the 5 day outlook already; however I really liked the weather underground because of the frequent updates. I think I will probably end up using the weather underground API as it seems pretty straight forward. Thanks for the idea pdabrowski. Will play with it when I get some more time to dedicate to it...other things got to get done...you know how that goes..
Sign In or Register to comment.