Samchon Framework for CPP  1.0.0
http_main.cpp
1 #include <iostream>
2 #include <fstream>
3 
4 #include <vector>
5 #include <string>
6 #include <thread>
7 
8 #include <samchon/library/HTTPLoader.hpp>
9 #include <samchon/library/URLVariables.hpp>
10 #include <samchon/library/Charset.hpp>
11 
12 #include <Windows.h>
13 
14 using namespace std;
15 using namespace samchon;
16 using namespace samchon::library;
17 
18 #ifdef _WIN64
19 # ifdef _DEBUG
20 # pragma comment(lib, "x64/Debug/SamchonFramework.lib")
21 # else
22 # pragma comment(lib, "x64/Release/SamchonFramework.lib")
23 # endif
24 #else
25 # ifdef _DEBUG
26 # pragma comment(lib, "Debug/SamchonFramework.lib")
27 # else
28 # pragma comment(lib, "Release/SamchonFramework.lib")
29 # endif
30 #endif
31 
32 void login();
33 void loadPage();
34 void loadFile();
35 
36 void toClipboard(const std::string &);
37 
38 void main()
39 {
40  setlocale(LC_ALL, "korean");
41 
42  login();
43  loadPage();
44  loadFile();
45 
46  system("pause");
47 }
48 
49 void login()
50 {
51  HTTPLoader loader("http://www.bomtvbiz.com/ad/?c=login", HTTPLoader::POST);
52  URLVariables data;
53  {
54  data["m_id"] = "rprt01";
55  data["password"] = "1234";
56  }
57 
58  string &str = loader.load(data).read<string>();
59  cout << str << endl << endl;
60  //cout << loader.load(data).read<string>() << endl << endl;
61 }
62 void loadPage()
63 {
64  //http://www.bomtvbiz.com/ad/
65  //http://samchon.org/simulation/php/corporate/list.php
66  HTTPLoader loader("http://samchon.org/simulation/php/corporate/list.php", HTTPLoader::GET);
67  URLVariables data;
68  {
69  data["c"] = "order";
70  data["a"] = "outsourcing";
71  data["page"] = "2";
72  }
73 
74  //cout << "#size: " << loader.load(data).size() << endl;
75  string &str = loader.load(data).read<string>();
76  toClipboard(str);
77 }
78 void loadFile()
79 {
80  HTTPLoader loader(Charset::toUTF8("http://www.bomtvbiz.com/dt/order_print/1448241706869/20151123_1448241706869_±èÇö¿ì_2¸í_±è ½Â ÁÖ.pdf"), HTTPLoader::GET);
81  ByteArray &data = loader.load({});
82 
83  // ÆÄÀÏ ÀúÀå
84  ofstream file("E:\\test.pdf", ios::out | ios::binary);
85  file.write((const char*)&data[0], data.size());
86 
87  file.close();
88 }
89 
90 void toClipboard(const string &str)
91 {
92  OpenClipboard(0);
93  EmptyClipboard();
94  HGLOBAL hg = GlobalAlloc(GMEM_MOVEABLE, str.size() + 1);
95 
96  if (!hg)
97  {
98  CloseClipboard();
99  return;
100  }
101  memcpy(GlobalLock(hg), str.c_str(), str.size() + 1);
102 
103  GlobalUnlock(hg);
104  SetClipboardData(CF_TEXT, hg);
105  CloseClipboard();
106  GlobalFree(hg);
107 }
Definition: RWMutex.hpp:4
Package of libraries.
Definition: library.hpp:84
A http, web-page loader.
Definition: HTTPLoader.hpp:23
Binary data class.
Definition: ByteArray.hpp:30
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7
URLVariables class is for representing variables of HTTP.