Hi Phil,

Would you please try the following:
                user_agent = {'User-Agent': 'Mozilla/5.0'}
                requester = six.moves.urllib.request.Request(u, 
headers=user_agent)
                response = request.urlopen(requester)
                return response.read().decode('utf-8')

If that doesn’t work, I can get it working tonight (day job getting in the way).
Also, it would be helpful if you could add:
log.info(u)
before the call and tell me what the log says is the URL.
I believe I can’t get a UK Met Office forecast in California.


> On Apr 9, 2020, at 11:57 AM, Phil Owers <[email protected]> wrote:
> 
> 
> Hi John
> Just need to tweek the forecast.py so it can download from the UK Met Office.
> They changed a few weeks ago to only excepting   'User-Agent', 'Mozilla/5.0 
> 
> In the forecast.py you sent me it had 
> response = six.moves.urllib.request.urlopen(u)
> return response.read().decode('utf-8')
> 
> My previous forecast.py I used
> 
> req = urllib2.Request(u)
> req.add_header('User-Agent', 'Mozilla/5.0')
> response = urllib2.urlopen(req)
> return response.read()
> But I cant get that to work any chance you could help out please.   Sorry to 
> be a pain
> Phil
> 
> 
>                
>                 
>                 
> 
>> On Wednesday, April 8, 2020 at 3:11:31 PM UTC+1, Phil Owers wrote:
>> Just downloaded the forecast extension which was 3.3.2.which I think is the 
>> latest on to a python 3 only machine (weewx 4.0.0b18) and it fails 
>> forecast.py Line 567 except OSError , e; with an underscore under the ,
>> Just wondered if anybody else has had this.
>> Cheers Phil
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/weewx-user/e9b708ad-835c-40bb-a0a8-1899260f5cec%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/198CBEB3-EA0D-4EC0-9677-F58943BC5E6D%40johnkline.com.

Reply via email to