ScrapperMin - Scripting Language for Web Automation

botwriter

Banned
Joined
Feb 20, 2015
Messages
23
Reaction score
0
Hi all

I am new, and I want to share my software (no virus/trojan), at
mekaskus.tk/ScrapperMin

The idea is like this.
I have been thinking that a scripting language is needed to do POST/GET for website that makes coding easier. Why? Because it is quite complex to even get a <input> tag name/value from C#, which needed HTMLAgility pack or manually using IndexOf, then Substring etc

For every internet POST/GET, <form> tag is used to do POST/GET. Then there is security token inside the form to prevent cross site scripting, and we need to get the security token in order to do automatic web posting.

After writing several bots for website (auto post/auto bump/auto comment/auto private message). I come to think that a scripting language is needed because of all questions I can think of.

Then I write a Parser and create my own scripting language and name it "ScrapperMin".

To try the parser, I make an automation script to bump thread using script below.

Code:
SET('PG', WC_GetPage('hxxp://forums.hardwarezone.com.sg', ''));
SET('PS', WC_GetPostStringRaw('hxxp://forums.hardwarezone.com.sg', GET('PG'), '1', FORMAT('vb_login_username={PARAM0}&vb_login_md5password_utf={0}&vb_login_md5password={1}', SO_GetMd5Hash('{PARAM1}'),SO_GetMd5Hash('{PARAM2}')), ''));
SET('PG2', WC_PostPageComplete(WC_GetLastActionUrl(), GET('PS'), 'hxxp://forums.hardwarezone.com.sg'));
IF(GET('PG2'), 'CONTAINS', 'Thank you for logging', 
    LOG('Successfully Login');
    SET('PG3', WC_GetPage('{PARAM3}', ''));
    SET('URL', JOIN('', 'hxxp://forums.hardwarezone.com.sg/newreply.php?do=newreply&noquote=1&p=', FILTER('0', SO_TagMatch(GET('PG3'), '/newreply.php?do=newreply&noquote=1&p=', '"'))));
    SET('PG4', WC_GetPage(GET('URL'), 'hxxp://forums.hardwarezone.com.sg'));
    SET('PS2', WC_GetPostStringRaw(GET('URL'), GET('PG4'), '3', 'message={PARAM4}', 'preview'));
    SET('PG5', WC_PostPageComplete(WC_GetLastActionUrl(), GET('PS2'), GET('URL')));
    EXIT('Post successfully');
LOG(GET('PG5'));
,EXIT('Invalid Login'));

Basically the script is a C like script, where Function1(function2(function3), function2b()); etc like except that you can create array of string using
Code:
MyFunc('first string';'second string', 'third string')
Where MyFunc will accept a parameter with string[] and second parameter with string.

Back to above script, there interesting part is : WC_GetPostStringRaw

Which will get the POST string format "username=myid&password=mypass&securitytoken=AutoGetFromForm" and you just need to pass in myid and mypass, and the securitytoken etc and all other input inside the form index '1' of that page will be created, and you only pass what interest you to fill in, like the username, and password.

{PARAM0}, {PARAM1} and {PARAM2} is username, password and password again. The script detect {PARAM and whenever it detects it, it will replace with the script argument files. you run the script using
Code:
scrappermin.exe -scr=HWZ.txt -args=param.txt

where param.txt is
Code:
[param]
userid
[param]
password
[param]
password
[param]
hxxp://threadurltobump
[param]
message of bump

Of course you need to register in the site before actually able to run the script successfully.

After having the POST string, you just call WC_PostPageComplete, to do POST using your final POST string where you have filled in the required fill such as username and password. And it will return the webpage and we check for string "Thank you for logging", if exist basically we have successfully log into the site.

What we do next is to find the thread ID by first getting the page content into PG3, and scrape the page ID that will be in the end of this string "newreply&noquote=1&p=". We use FILTER to get the first (index 0) of the occurence, and leave the rest. Then concatenante with the forum reply url using JOIN.

Finally we get the page to do posting of the forum. and using WC_GetPostStringRaw to get the form at index 3 which is the form to fill in for posting comment, we fill in "message" value pair with our input at {PARAM4} and remove the preview key pair and do a post.

And we shall see our comment posted to the forum.
ScrapperMin.exe can be scheduled in Task Scheduler and the parameter must be put correctly, then periodically it will bump your thread.

You can create your own script using ScrapperMinW.exe (windows form) and test run it, once successful you can write your own script to do Web Automation task of any website you need.

Feel free to post here to discuss.
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,550
Reaction score
1,302
If you have such need for parsing, your better tools are perl and curl and dom and xpath

There tools are far less rigid and provides all the features you need to traverse the source, using regular expressions or maybe even dom to extract your required parts and perform all the necessary post and get.

Using the developer tool in google chrome or firefox will be also very helpful for such endeavour.
 

botwriter

Banned
Joined
Feb 20, 2015
Messages
23
Reaction score
0
If you have such need for parsing, your better tools are perl and curl and dom and xpath

There tools are far less rigid and provides all the features you need to traverse the source, using regular expressions or maybe even dom to extract your required parts and perform all the necessary post and get.

Using the developer tool in google chrome or firefox will be also very helpful for such endeavour.

hi davidktw, yeah its true
i love curl but it just that it does not have manage library

so i choose to write my own, which is a bit less powerful, but I am learning to write one and it can be useful for learning parsering syntax. my real motivation is learning the basic of parsing, and see that I can develop one.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,550
Reaction score
1,302
hi davidktw, yeah its true
i love curl but it just that it does not have manage library

Manage library ? I don't quite understand, much of the general programming languages today in some way integrate with libcurl to provide an integrated library or module of Curl within the language. You can take a look at libcurl - Bindings to know which are the available ones, probably not even exhaustive.

so i choose to write my own, which is a bit less powerful, but I am learning to write one and it can be useful for learning parsering syntax. my real motivation is learning the basic of parsing, and see that I can develop one.

I think it is indeed very good that you get your hands on creating your own tool or scripting language for an educational purpose and also sharing it. If so, I believe you might want to consider contributing to some other tools and bring more value into them in time to come such as phantomjs, zombie.js or slimjs or at least in some way integrate with them since nowadays parsing are not necessarily sufficient for web scraping anymore :) Some more of active integration with a JS runtime engine may very well be necessary.

But still, keep it up :)
 

botwriter

Banned
Joined
Feb 20, 2015
Messages
23
Reaction score
0
hi maybe i spell wrongly, it is managed library not manage library.
basically it is .NET language using intermediate language

because as far as i know curl is written in C++ and ported to linux/windows/mac, and it is native code. Unlike managed code, native code has its downside since it is tightly couple with CPU and generates different issue under different hardware.

maybe i will learn a bit of phantomjs, just can't find a good book or guide about it, the site has same example but not really make me understand whats make it special. If learning JS, i will choose nodejs, since it is fast and used for server side processing of HTTP request, but it is very difficult, I read several pages and begin to have headache, LOL.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,550
Reaction score
1,302
hi maybe i spell wrongly, it is managed library not manage library.
basically it is .NET language using intermediate language

because as far as i know curl is written in C++ and ported to linux/windows/mac, and it is native code. Unlike managed code, native code has its downside since it is tightly couple with CPU and generates different issue under different hardware.

The JVM, Python, Perl, Python, Javascript interpreters and compilers are all written using unmanaged codes. How much of the programming languages themselves operates differently across the various platforms that they are work on ? Granted there are features in some of them such as the Win32API in Windows platform not found in the Unix platform, question is did the regex works differently in one machine than the other ?

Managed or better should be called portable codes should operate differently from one machine architecture to another, but consistency in behaviour doesn't necessarily comes with different architecture. You have to really see what you are dependent on when on 2 different architectures.

Much of CURL is on the network layer and there are pretty consistent across the different platforms, so I don't think libcurl should operates differently with respect to simple request methods or the treatment of headers and the body of the contents.

The API is also established between the different bindings, so it's just a matter of how to use them properly in each binding.

There is no certainty in your assumption that a library must break or highly probable to break or differs under different architecture. You have to consider how deep does your codes need to depend on the specific architecture of a machine.

maybe i will learn a bit of phantomjs, just can't find a good book or guide about it, the site has same example but not really make me understand whats make it special. If learning JS, i will choose nodejs, since it is fast and used for server side processing of HTTP request, but it is very difficult, I read several pages and begin to have headache, LOL.

I'm afraid much of these open source tools are provided as-is. You will need to scrap around for knowledge on how to use them properly and I'm sure you are not the first one attempting it, so you should be able to search for some solutions here and there. Forums are also where you want to find people helping you on your doubts.

Node.js is not your typical top-down approach of programming, but actually once you get your head around event driven and some functional programming paradigm, it is quite interesting.

PhamtomJS and the related are automation as a web client with the power to provide JS runtime. How are you going to scrap on the source if it is not even readily there in the DOM in the first place ? What if I give you a Single-Page Application website, how are you going to scrap effectively using parsing source code to tell you how to proceed ? In such instant, much of the logic are already built into the client code that is running in the browser, so without a runtime engine to execute, you can't have a complete picture of what the website is for you to proceed scrap. The runtime engine helps to build the client side of the site, so that you will have more or less the DOM necessary for you to work on.

You can of course go into the effort of providing such a runtime using your own brew or javascript library, but still you need to also provide the DOM for your own code to work on. Effectively you are building a headless browser, which I deem as one of the most complicated assignment you can take on. Parsing HTML + CSS + Javascript is not exactly easy.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,550
Reaction score
1,302
Just for fun, want curl to run off the javascript engine, use emscripten. It will indeed be a kind of the managed code you may want to try for fun :) Who knows with enough testing, it can indeed be production enough

How to do it ?
1) Download the curl source code
2) Get your own installation of emscripten
3) configure and compile into libcurl.js

Then you can run code like this inside node.js
Code:
var curl = require("./libcurl.js");
var vptr = curl.ccall("curl_version", "string", "[]", "[]");
console.log(vptr);

Output:
Code:
$ node test.js
libcurl/7.41.0-DEV

You may download the compiled JS libcurl from libcurl.js

SHASUM
Code:
051c3d0b034e9654abe6df2f1f04e4c52797eccc  libcurl.js

Have fun :)
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top