Created
May 15, 2011 02:53
-
-
Save navinpai/972851 to your computer and use it in GitHub Desktop.
HTML Number to Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********************************************************************************** | |
Basically takes a file with HTML numbers as input and outputs the converted text to another file. | |
HTML Numbers is: | |
A A | |
B A | |
etc. | |
Mainly did this to decrypt(?) lyrics from lyrics sites like SongLyrics.com which allow only viewing but not copying of lyrics (The whole GraceNote license thing) eg. http://www.songlyrics.com/flobots/we-are-winning-lyrics/ ... source code of the page shows the lyrics in HTML numbers. | |
Compiled with Codeblocks v. 8.02 | |
To run, use "executable name i/p-file o/p-file" i.e command line arguments | |
***********************************************************************************/ | |
#include <iostream> | |
#include<conio.h> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
int main (int argc,char* argv[]) { | |
string line;char c,d,e;int x;char h; | |
if(argc<3) | |
{cout<<"\n\n\t\tProvide filename of HTML op as argument \n\t\tand Output file as 2nd argument\n"; | |
cout<<"\n\t\teg:"<<argv[0]<<" input.txt mylyrics.txt\n"; | |
return 0; | |
} | |
ifstream ip (argv[1]); | |
ofstream op (argv[2]); | |
if (ip.is_open()) | |
{ | |
while ( ip.good() ) | |
{ | |
ip.read((char*)&c,sizeof(c)); | |
//CASE1 | |
if(c=='&') | |
{ | |
ip.read((char*)&d,sizeof(d)); | |
if(d=='#'); | |
else | |
cout<<"&"; | |
}//CASE2 | |
else if(c=='#'); | |
//CASE3 | |
else if(c==';'); | |
else if(c=='<') | |
{ | |
while(c!='>') | |
ip.read((char*)&c,sizeof(c)); | |
} | |
//CASE4 | |
else if(c>='0'&&c<='9') | |
{x=atoi(&c); | |
while(d!=';') | |
{ | |
ip.read((char*)&d,sizeof(d)); | |
if(d==';') | |
break; | |
else | |
{ | |
x=x*10+d-48; | |
} | |
} | |
h=char(x); | |
op << h; | |
} | |
else op<<c; | |
} | |
ip.close(); | |
} | |
else cout << "Unable to open file"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment