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.

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.