Jump to content

[SOLVED] Retrieve random string from page using cURL?


slpctrl

Recommended Posts

First you need to use a regular curl request to fetch the data of the page. Then you'll need to use some regex to keep only the part of the page you want, and then it's just about using base64_decode().

Getting the contents of the page shouldn't be a problem, a regular curl query.

Obtaining the part of the text you need is generally the tricky part- but that depends on how the HTML of that page looks like. If you are having problems with this part, post here (or in the regex board) how the HTML looks like (some kind of an example), and someone will help you find out how get the part you need.

 

Orio.

Link to comment
Share on other sites

The section of the page is seperated with the <div> tag like so:

 

 

<div class='main-body'>

<div style="text-align: center;">

<br /><br />

Random string: X3AtMGssLGB6KDZhY2lgXw==<br /><br />

</div>

 

How do I use that to retrieve the text? The encoded text is surrounded by text.

Link to comment
Share on other sites

So you can use a simple regular expression to get the data:

 

<?php

preg_match_all("/Random string: ([a-zA-Z0-9=+\/]*)/", $html, $matches);
print_r($matches[1]);

?>

 

Orio.

 

Alright, this is very close to what I need. Now, after some adjusting I've got the random string however it's in an array with only 1 element. How can I get that array to be a plain text variable with only the string?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.