Jump to content
UBot Underground

Similar to Page Scrape but from a Variable?


Recommended Posts

Hello.

 

I have the html code of a website in a variable.

Now I want to extract a specific information out of this variable.

 

The easiest would be, if I could use something similar to $Page scrape.

Where I just enter:

text on left side

text on right side.

 

But instead of doing that from tha actual page I'm on, I need to do that from the text within a variable.

 

Within the html code ther is:

<meta name="csrf-token" content="22546d0ed677b61e4073515e847773b52a363f1a882e45afa75eb87ad29c375cb9eab5024cafbc6ae1783d7d42fc73a54174ecb7bf4b82edadc8fe358a71f6ee">

 

And I need to extract only the token from the html text in the variable.

 

 

What is the easiest way to extract parts of a text from another text? I looked at the text and search functions within ubot, but wasn't able to find anything that is similar to the $Page scrape command.

 

Thanks in advance for your help

Dan

Link to post
Share on other sites

set(#sourceString"<meta name=\"csrf-token\" content=\"22546d0ed677b61e4073515e847773b52a363f1a882e45afa75eb87ad29c375cb9eab5024cafbc6ae1783d7d42fc73a54174ecb7bf4b82edadc8fe358a71f6ee\">""Global")
set(#extractedStr$list item($find regular expression(#sourceString"(?<=<meta name=\"csrf-token\" content=\")[a-zA-Z0-9]*(?=\">)"), 0), "Global")

 

 

The extracted string is in the variable #extractedStr .

 

 

If  #sourceString is a web page you could extract the extracted string from "$document text" instead.

Link to post
Share on other sites

Hello.

 

I have the html code of a website in a variable.

Now I want to extract a specific information out of this variable.

 

The easiest would be, if I could use something similar to $Page scrape.

Where I just enter:

text on left side

text on right side.

 

But instead of doing that from tha actual page I'm on, I need to do that from the text within a variable.

 

Within the html code ther is:

<meta name="csrf-token" content="22546d0ed677b61e4073515e847773b52a363f1a882e45afa75eb87ad29c375cb9eab5024cafbc6ae1783d7d42fc73a54174ecb7bf4b82edadc8fe358a71f6ee">

 

And I need to extract only the token from the html text in the variable.

 

 

What is the easiest way to extract parts of a text from another text? I looked at the text and search functions within ubot, but wasn't able to find anything that is similar to the $Page scrape command.

 

Thanks in advance for your help

Dan

 

A couple other ways would be to do the $substring of the variable using $find index to find your start point and $text length minus $find index to cut off the first portion.  Then do another $substring from 0 to $find index of the last character in the string you need.

 

Another solution would be to load the variable as html and run $page scrape that way.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...