It is currently March 28th, 2024, 9:12 pm

How to get a redirect url

Get help with creating, editing & fixing problems with skins
simsrw73

How to get a redirect url

Post by simsrw73 »

I've searched the forums and this doesn't seem to be supported directly from WebParser. Is there some kind of work-around? I would think this would be pretty common. I'm working from one of the following urls:

http://bible.faithlife.com/verseoftheday/2019-02-07
http://bible.faithlife.com/verseoftheday/lightbox/2019-02-07

I'd like to get either the redirect url from the header or the redirected page. Specifically, I'm trying to get from the date based url to derive the bible reference which is in the redirect url and the redirected page.

Code: Select all

H:\Home> wget --max-redirect=0 https://bible.faithlife.com/verseoftheday/lightbox/2019-02-07
--2019-02-07 08:05:00--  https://bible.faithlife.com/verseoftheday/lightbox/2019-02-07
Resolving bible.faithlife.com (bible.faithlife.com)... 192.58.0.33
Connecting to bible.faithlife.com (bible.faithlife.com)|192.58.0.33|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: [b]/verseoftheday/lightbox/Ps139.9-10[/b] [following]   <--- I Want the reference here or the content of that page for a WebParser RegExp
0 redirections exceeded.
How do you deal with redirects?
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: How to get a redirect url

Post by ikarus1969 »

Do you know of RainRegExp, a regular-expression tester, which user jsmorley has provided? You can find it here: https://forum.rainmeter.net/viewtopic.php?f=127&t=769

With that you can test regular-expressions.

If i use it for parsing one of your URLs - http://bible.faithlife.com/verseoftheday/lightbox/2019-02-07 - and enter the regular expression

Code: Select all

(?siU)<link rel="image_src" href="(.+)\?.+"
you get the url you have asked for, right?
SS RainRegExp.jpg
With this URL you can feed another webparser measure to get the picture.

May this be a solution for you?

(So, the first webparser measure for the original URL http://bible.faithlife.com/verseoftheday/lightbox/2019-02-07 and the second one for the retrieved URL)
You do not have the required permissions to view the files attached to this post.
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: How to get a redirect url

Post by ikarus1969 »

Oh, i see i've misunderstood you - sorry. My post isn't related to your question :?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to get a redirect url

Post by jsmorley »

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureDate]
Measure=Time
Format=%Y-%m-%d

[MeasureSite]
Measure=WebParser
URL=http://bible.faithlife.com/verseoftheday/[&MeasureDate]
RegExp=(?siU)<link rel="image_src" href="(.*)\?width=(.*)".*<meta property="og:title" content="(.*)"
DynamicVariables=1
FinishAction=[!ShowMeterGroup Verse][!UpdateMeterGroup Verse][!Redraw]

[MeasureImage]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
Download=1
DownloadFile=TodayVerse.jpg

[MeasureReferenceFromImage]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
RegExpSubstitute=1
Substitute="http://bible.faithlife.com/verseoftheday/image/(.*)$":"\1"

[MeasureWidth]
Measure=WebParser
URL=[MeasureSite]
StringIndex=2

[MeasureVerse]
Measure=WebParser
URL=[MeasureSite]
StringIndex=3

[MeterImage]
Meter=Image
Group=Verse
MeasureName=MeasureImage
W=([MeasureWidth])
PreserveAspectRatio=1
DynamicVariables=1
Hidden=1

[MeterVerse]
Meter=String
Group=Verse
MeasureName=MeasureVerse
X=([MeasureWidth]/2)
Y=5R
StringAlign=Center
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Hidden=1

[MeterReference]
Meter=String
Group=Verse
MeasureName=MeasureReferenceFromImage
X=([MeasureWidth]/2)
Y=5R
StringAlign=Center
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Hidden=1
1.jpg
You do not have the required permissions to view the files attached to this post.
simsrw73

Re: How to get a redirect url

Post by simsrw73 »

jsmorley wrote: February 7th, 2019, 2:39 pm

Code: Select all

[Rainmeter]
...
Wow! Thanks for your time and help. Makes me feel incredibly clumsy in my attempts. Quite a few points to learn from your code. Thank you!
ikarus1969 wrote: February 7th, 2019, 1:37 pm Do you know of RainRegExp, a regular-expression tester, which user jsmorley has provided?
Thank you for this. Didn't know about that tool. It will definitely be helpful.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to get a redirect url

Post by jsmorley »

simsrw73 wrote: February 7th, 2019, 3:21 pm Wow! Thanks for your time and help. Makes me feel incredibly clumsy in my attempts. Quite a few points to learn from your code. Thank you!
Glad to help.Let me now if you have questions.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to get a redirect url

Post by jsmorley »

Note that that will create one or more non-fatal errors in the log when the skin is first loaded or when refreshed, due to there not being any value yet in [MeasureWidth], and us using that in formulas.

This can be corrected like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
ImageWidth=0

[MeasureDate]
Measure=Time
Format=%Y-%m-%d

[MeasureSite]
Measure=WebParser
URL=http://bible.faithlife.com/verseoftheday/[&MeasureDate]
RegExp=(?siU)<link rel="image_src" href="(.*)\?width=(.*)".*<meta property="og:title" content="(.*)"
DynamicVariables=1
FinishAction=[!SetVariable ImageWidth "[MeasureWidth]"]

[MeasureImage]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
Download=1
DownloadFile=TodayVerse.jpg
FinishAction=[!ShowMeterGroup Verse][!UpdateMeterGroup Verse][!Redraw]

[MeasureReferenceFromImage]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
RegExpSubstitute=1
Substitute="http://bible.faithlife.com/verseoftheday/image/(.*)$":"\1"

[MeasureWidth]
Measure=WebParser
URL=[MeasureSite]
StringIndex=2

[MeasureVerse]
Measure=WebParser
URL=[MeasureSite]
StringIndex=3

[MeterImage]
Meter=Image
Group=Verse
MeasureName=MeasureImage
W=#ImageWidth#
PreserveAspectRatio=1
DynamicVariables=1
Hidden=1

[MeterVerse]
Meter=String
Group=Verse
MeasureName=MeasureVerse
X=(#ImageWidth#/2)
Y=5R
StringAlign=Center
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Hidden=1

[MeterReference]
Meter=String
Group=Verse
MeasureName=MeasureReferenceFromImage
X=(#ImageWidth#/2)
Y=5R
StringAlign=Center
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Hidden=1
That is because the string value of [MeasureWidth] will initially be "" or an empty string, and you can't use strings in formulas. Once it has the width, the string value will be 700, or 500, or whatever it is, and that can be recognized and used as a number in formulas.
itami2000
Posts: 2
Joined: February 25th, 2019, 9:22 pm

Re: How to get a redirect url

Post by itami2000 »

HOW TO PROGRAM FOR THIS SITE?


https://dailyverses.net/pt


To get the image?






jsmorley wrote: February 7th, 2019, 2:39 pm

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureDate]
Measure=Time
Format=%Y-%m-%d

[MeasureSite]
Measure=WebParser
URL=http://bible.faithlife.com/verseoftheday/[&MeasureDate]
RegExp=(?siU)<link rel="image_src" href="(.*)\?width=(.*)".*<meta property="og:title" content="(.*)"
DynamicVariables=1
FinishAction=[!ShowMeterGroup Verse][!UpdateMeterGroup Verse][!Redraw]

[MeasureImage]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
Download=1
DownloadFile=TodayVerse.jpg

[MeasureReferenceFromImage]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
RegExpSubstitute=1
Substitute="http://bible.faithlife.com/verseoftheday/image/(.*)$":"\1"

[MeasureWidth]
Measure=WebParser
URL=[MeasureSite]
StringIndex=2

[MeasureVerse]
Measure=WebParser
URL=[MeasureSite]
StringIndex=3

[MeterImage]
Meter=Image
Group=Verse
MeasureName=MeasureImage
W=([MeasureWidth])
PreserveAspectRatio=1
DynamicVariables=1
Hidden=1

[MeterVerse]
Meter=String
Group=Verse
MeasureName=MeasureVerse
X=([MeasureWidth]/2)
Y=5R
StringAlign=Center
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Hidden=1

[MeterReference]
Meter=String
Group=Verse
MeasureName=MeasureReferenceFromImage
X=([MeasureWidth]/2)
Y=5R
StringAlign=Center
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Hidden=1

1.jpg
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to get a redirect url

Post by balala »

itami2000 wrote: April 11th, 2019, 5:05 am HOW TO PROGRAM FOR THIS SITE?


https://dailyverses.net/pt


To get the image?
Does the URL of the image changing? Because if it doesn't, it's quite simple, otherwise it's a little bit more complicated, but probably not impossible, nor then. If it doesn't change, use the following WebParser measure to get it:

Code: Select all

[MeasureSite]
Measure=WebParser
URL=https://dailyverses.net/images/pt/ARC/proverbios-10-9.jpg
Download=1
So, does it change?
itami2000
Posts: 2
Joined: February 25th, 2019, 9:22 pm

Re: How to get a redirect url

Post by itami2000 »

How to parse this image? <img src="/images/pt/ARC/proverbios-10-9.jpg" srcset="/images/pt/arc/xl/proverbios-10-9.jpg 2x"

Code: Select all

[Rainmeter]
Update=3600
;To make this to immediately show up, change value to 0 and refresh.

[MeasureDate]
Measure=Time
Format=%Y%m%d

[MeasureURL]
Measure=String
String=https://dailyverses.net/pt/[&MeasureDate]
DynamicVariables=1

[MeasureSite]
Measure=Plugin
Plugin=WebParser
MeasureName=MeasureURL
URL=[&MeasureURL]
RegExp=(?siU)<img src="/images/pt/ARC/(.*)" .*</div>
DynamicVariables=1

[MeasureImage]
Measure=WebParser
URL=https://dailyverses.net/images/pt/ARC/[MeasureSite]
StringIndex=1
Download=1
DownloadFile=[MeasureDate].jpg

[MeterImage]
Meter=Image
MeasureName=MeasureImage
H=228
W=378
Last edited by balala on April 11th, 2019, 11:47 am, edited 1 time in total.
Reason: Please use <code> tags, whever are you posting code snippets. It's the </> button.