On a similar note, I'm trying to make a 3rd party "script" in c++ (raw console) in order to strip an image URL of 2 values, and convert them to an integer. The site I'm ripping contains a web link like http://[some-static-site]/in=aha&l=3&[other static info]. aha (length 3) returns an image printing the number 101.
[]&in=atqregixh&l=9[] = 124567890
*Note: l=* returns the length of the number, and all letters are static, as they are not securely encrypted
Rather than my original method of ripping data (custom web page running custom java-script code), I'm trying to use the new function to run a self-designed command to convert the image to an integer so i can handle the info accordingly.
Current (completed) C++ Code *EDIT: unfinished to completed
Code: Select all
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
using namespace std;
struct list {
string letter;
int value;
};
list encr[10] = {
{ "a", 1 },
{ "t", 2 },
{ "y", 2 }, // Yes, that's right, 2 2's and no 3's
{ "q", 4 },
{ "r", 5 },
{ "e", 6 },
{ "g", 7 },
{ "i", 8 },
{ "x", 9 },
{ "h", 0 }
};
int main (int argsc, char* argsv[])
{
// Make sure we're only dealing with the command and the link...
if (argsc == 2) {
int val = 0; // Reset our number (just in case)
string link = argsv[1]; // Set our link for variable-friendly naming
// find the cursor points in the link
int start = (link.find("?in=")+4); // find() is the shortest method to locating
int end = link.find("&l=",start); // our variable-length string
// find our fail encrypted text segment
string encrypted = link.substr(start,(end - start));
int length = atoi(link.substr(end+3,1).c_str());
// Lets print the stuff for fun?
cout << "Encrypted String = " << encrypted << " (" << length << ");" << endl;
for ( int i = 0; i < length; i++) { // once for every character in the encrypted string
for ( int c = 0; c < 10; c++) { // once for every character in our table
if (encr[c].letter == encrypted.substr(i,1)) { // We found it!
// conversion formula =
// value = value + (number * (10 ^ ((length - digit) - 1)))
double dval = pow(double(10),(length-(i+1))); //pow() only deals in doubles
int ival = encr[c].value * (int(dval)); // we want an integer
val += ival;
break; // save us some loop trouble
}
}
}
if (val < 200) { // value isn't worth the effort
cout << val << " isn't worth it..." << endl;
} else if (val < 1000) { // value is worth the effort
cout << val << " will work..." << endl;
} else { // omg thats a sexy number
cout << val << "? DO IT!!!" << endl;
}
return val; // make our return and lets get outta here
} else { // yo, think your script is bugged...
return 0; // errors return a value of 0
}
}
*Note: Returns 0 if you entered an invalid quantity of arguments (maybe script error?), or the number that the image would show.
Running "C:\ConvertImg.exe" with arg1 being the link, how can I obtain and handle the return value?
> Reading further into it, I think using the Run() command to execute my app only works for java-script or vb-script web documents... If that's so, i might as well rebuild all of this in java-script like i use to?