dcapslock / weewx-responsive-skin

Weewx Responsive Skin using the Bootstrap framework
22 stars 9 forks source link

BOM warnings no longer work #12

Closed rodyager closed 3 years ago

rodyager commented 3 years ago

BOM warnings no longer work as the BOM server responds with a forbidden error code. The work around is to provide a more complete header as a browser would do.

For instance, I define self.user_headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Cache-Control': 'max-age=0', 'Accept-Language': 'en-au', 'Upgrade-Insecure-Requests': '1', 'Host': 'www.bom.gov.au', 'Referer': 'http://www.bom.gov.au/', 'Accept-Encoding': 'deflate', 'Connection': 'keep-alive'}

and use this as the header for all the requests.

These headers were copied from those submitted by my web-browser, minus the cookie and the gzip Accept-Encoding.

dcapslock commented 3 years ago

Thanks for this pick up. Changing the header will work, but BOM will probably catch up and block it, so developing a random method for user agent may be more robust.


From: Rod Yager @.> Sent: Wednesday, April 28, 2021 10:33:19 AM To: dcapslock/weewx-responsive-skin @.> Cc: Subscribed @.***> Subject: [dcapslock/weewx-responsive-skin] BOM warnings no longer work (#12)

BOM warnings no longer work as the BOM server responds with a forbidden error code. The work around is to provide a more complete header as a browser would do.

For instance, I define

self.user_headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'Cache-Control': 'max-age=0', 'Accept-Language': 'en-au', 'Upgrade-Insecure-Requests': '1', 'Host': 'www.bom.gov.au', 'Referer': 'http://www.bom.gov.au/',\https://apac01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.bom.gov.au%2F%27%2C%255C&data=04%7C01%7C%7Cf97ff0d8ab224cebfbda08d909dd39cc%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637551668022305747%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2FK%2F01FkblSlKiHuLmUtHAi%2BH5bDc0Nkl2Gzx2kBWZss%3D&reserved=0 'Accept-Encoding': 'deflate', 'Connection': 'keep-alive'}

and use this as the header for all the requests.

These headers were copied from those submitted by my web-browser, minus the cookie.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdcapslock%2Fweewx-responsive-skin%2Fissues%2F12&data=04%7C01%7C%7Cf97ff0d8ab224cebfbda08d909dd39cc%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637551668022315746%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=a3Yme9buFceZMmZ0elgMi1ZGw4P2VWPGgScdrXvH35c%3D&reserved=0, or unsubscribehttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADLXZBWFGK6VY3F6J6P4BITTK5JU7ANCNFSM43WANDIQ&data=04%7C01%7C%7Cf97ff0d8ab224cebfbda08d909dd39cc%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637551668022315746%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yoHZ5tbNG9pFIpxsFFcVU6%2FRq4dtXF1MUZCdnfC8Um8%3D&reserved=0.

dcapslock commented 3 years ago

default user agent updated