Hi guys. I have a php script that reads some values off a website and prints to a file every second.. The thing is, the script is always ran in my browser and I don't like that.

I want to write a c++ program that can run that script within it and write the data to a file.

If that is not possible, can I use C++ to read the contents off of a website, given the link?

Example: The php script is given the link to the website and given the elements the data is contained in. It reads that into an array and prints the data to a file.. If the data is between two div tags with a unique ID, the php file will look for the div tags with that ID and print it to an array.. Can I do this in C++??

TLDR: Can C++ Run PHP scripts/files? Can C++ Read data from a website without opening my browser?

You could do it in either language.
If you don't like it running in the browser, you make a command-line version.

########################################################################
# Read content from a web page
$fileInFile=fopen("http://server.ext/Resources/SmallTextFile.txt", "rb");
while(!feof($fileInFile))
{
   $strData = fgets($fileInFile);
   printf($strData);
}
fclose($fileInFile);

You could do it in either language.
If you don't like it running in the browser, you make a command-line version.

########################################################################
# Read content from a web page
$fileInFile=fopen("http://server.ext/Resources/SmallTextFile.txt", "rb");
while(!feof($fileInFile))
{
   $strData = fgets($fileInFile);
   printf($strData);
}
fclose($fileInFile);

How would I do it in C++?

How would I do it in C++?

you can't do that with just pure C++. You will have to use external libraries like ncurses

you can't do that with just pure C++.

It would be difficult in "pure" C++.
I personnaly would use C++/CLI with the WebClient class and call the OpenRead() method that opens a Stream. I would feed that into a StreamReader and treat it like a file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.