-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpawnscraper.inc
148 lines (132 loc) · 3.66 KB
/
pawnscraper.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#if defined _inc_pawnscraper
#undef _inc_pawnscraper
#endif
#if defined _pawnscraper_included
#endinput
#endif
#define _pawnscraper_included
#define PAWN_SCRAPER_VERSION 22
#define INVALID_HTML_DOC (Html:-1)
#define INVALID_SELECTOR (Selector:-1)
#define INVALID_ATTRIBUTE (-2)
#define SCRAPER_ERROR (-1)
#define INVALID_HTTP_RESPONSE (Response:-1)
#define INVALID_HEADER (Header:-1)
public _pawnscraper_version = PAWN_SCRAPER_VERSION;
#pragma unused _pawnscraper_version
/*
ParseHtmlDocument(const document[])
Params
document[] - string of html document
Returns
- Html document instance id
- if failed to parse document INVALID_HTML_DOC is returned
*/
native Html:ParseHtmlDocument(const document[]);
/*
ResponseParseHtml(Response:id)
Params
id - Http response id returned from HttpGet
Returns
- Html document instance id
- if failed to parse document INVALID_HTML_DOC is returned
*/
native Html:ResponseParseHtml(Response:id);
/*
HttpGet(const url[],Header:headerid=INVALID_HEADER)
Params
url[] - Url of a website
header - id of header object created using CreateHeader
Returns
- Response id if successful
- if failed to INVALID_HTTP_RESPONSE is returned
*/
native Response:HttpGet(const url[],Header:headerid=INVALID_HEADER);
/*
HttpGetThreaded(playerid,const callback[],const url[],Header:headerid=INVALID_HEADER)
Params
playerid - id of the player
callback[] - name of the callback function to handle the response.
url[] - Url of a website
header - id of header object created using CreateHeader
*/
native HttpGetThreaded(playerid,const callback[],const url[],Header:headerid=INVALID_HEADER);
/*
ParseSelector(const string[])
Params
string[] - CSS selector
Returns
- Selector instance id if successful
- if failed to INVALID_SELECTOR is returned
*/
native Selector:ParseSelector(const string[]);
/*
CreateHeader(...)
Params
key value pairs
*/
native Header:CreateHeader(...);
/*
GetNthElementName(Html:docid,Selector:selectorid,idx,string[],size = sizeof(string))
Params
docid - Html instance id
selectorid - CSS selector instance id
idx - the n'th occurence of element in the document (starts from 0)
string[] - element name is stored
size - sizeof string
Returns
- 1 if successful
- 0 if failed
*/
native GetNthElementName(Html:docid,Selector:selectorid,idx,string[],size = sizeof(string));
/*
GetNthElementText(Html:docid,Selector:selectorid,idx,string[],size = sizeof(string))
Params
docid - Html instance id
selectorid - CSS selector instance id
idx - the n'th occurence of element in the document (starts from 0)
string[] - element name
size - sizeof string
Returns
- 1 if successful
- 0 if failed
*/
native GetNthElementText(Html:docid,Selector:selectorid,idx,string[],size = sizeof(string));
/*
GetNthElementAttrVal(Html:docid,Selector:selectorid,idx,const attribute[],string[],size = sizeof(string))
Params
docid - Html instance id
selectorid - CSS selector instance id
idx - the n'th occurence of element in the document (starts from 0)
attribute[] - the attribute of element
string[] - element name
size - sizeof string
Returns
- 1 if successful
- 0 if failed
*/
native GetNthElementAttrVal(Html:docid,Selector:selectorid,idx,const attribute[],string[],size = sizeof(string));
/*
DeleteHtml(Html:id)
Params
id - html instance to be deleted
*/
native DeleteHtml(Html:id);
/*
DeleteSelector(Selector:id)
Params
id - selector instance to be deleted
*/
native DeleteSelector(Selector:id);
/*
DeleteResponse(Html:id)
Params
id - response instance to be deleted
*/
native DeleteResponse(Response:id);
/*
DeleteHeader(Header:id)
Params
id - header instance to be deleted
*/
native DeleteHeader(Header:id);