I'm trying to make a weather skin with automatic location based on IP address
=> Retrieving city name from IP address Works!
=> Retrieving weatherCode for this city does NOT work
The [measureCity] result is not correct incorporated in the URL of [MeasureWeatherCode]
I also tried the Setvariable option but this also did not work ( See ; Lines )
It's not the perfect location, not the one I use in my skin(s), but since it is based on the local "point of presence" of your ISP, it's likely to be reasonably close.
I really think you need to use the combination of "city/region/country" to zero in. City and country alone will give you just boatloads of hits for most common names.
You do not have the required permissions to view the files attached to this post.
For such a thing I'm using a little bit different approach: I'm using a URL which directly returns the country, city, geographical coordinates, weather code and time zone (and even more, but these are the information I need), based on current IP address:
My only concern with "screen scraping" is that it can vary a bit depending on the detected browser, country and other factors. For instance, I get a parsing error with your code from the USA with Firefox, where I suspect you don't.
I could fix the regular expression, but I couldn't be certain it would then work for others.
Sometimes screen scraping is the best or even only way. I guess I'd be tempted to use a UserAgent string to at least force a distinct browser.
jsmorley wrote: ↑October 4th, 2019, 6:15 pm
My only concern with "screen scraping" is that it can vary a bit depending on the detected browser, country and other factors. For instance, I get a parsing error with your code from the USA with Firefox, where I suspect you don't.
Sometimes screen scraping is the best or even only way. I guess I'd be tempted to use a UserAgent string to at least force a distinct browser.
I'm not sure I understand what you mean by "screen scraping", but no, I'm not getting error messages at all when running my previous code.
And beside getting the error message, does the code returns the needed information?
balala wrote: ↑October 4th, 2019, 6:27 pm
I'm not sure I understand what you mean by "screen scraping", but no, I'm not getting error messages at all when running my previous code.
And beside getting the error message, does the code returns the needed information?
I just get a regular expression failure on the RegExp. I haven't looked at it really.
By "screen scraping", I mean just parsing web page source, that isn't certain to be standard, but might adjust itself based on what it thinks you are using to access it. So you are parsing more or less what you get on the "screen", rather than a json or xml "feed", that is going to be consistent.
As an example, these forums will output something entirely different if you are on a mobile device.
probably what jsmorley said is why i was unable to get any location data when pressed the Detect button of your Mirage suite...? But it worked on any PC you tested.
Last edited by pul53dr1v3r on October 4th, 2019, 7:20 pm, edited 1 time in total.
jsmorley wrote: ↑October 4th, 2019, 6:28 pm
I just get a regular expression failure on the RegExp. I haven't looked at it really.
And nothing returned by skin?
jsmorley wrote: ↑October 4th, 2019, 6:28 pm
By "screen scraping", I mean just parsing web page source, that isn't certain to be standard, but might adjust itself based on what it thinks you are using to access it. So you are parsing more or less what you get on the "screen", rather than a json or xml "feed", that is going to be consistent.
Ok, understood now.
jsmorley wrote: ↑October 4th, 2019, 6:28 pm
As an example, these forums will output something entirely different if you are on a mobile device.
Right, this is true. But does this matter when using WebParser measures to get the results into a skin? How does the skin detects the used web browser? I think I read once something about this here on forum, but I don't know what and I'm not sure now how to look for it.
But same question as for jsmorley above: does the skin return something, beside the error message?
Pul53dr1v3r wrote: ↑October 4th, 2019, 7:10 pm
to balala: probably what jsmorley said is why i was unable to get any location data when pressed the Detect button of your Mirage suite...? But it worked on any PC you tested.
Take care, although I sent you the Mirage for testing, the public don't know yet what Mirage is.
If anyone interested: it'll be my brand new skins suite, which I'll publish soon. Although not long ago I thought it is ready, in meantime I found a bug, which I'm working on now to fix it.