c# 4.0 - Executing stored CSQueries -


i trying create crawler need able execute different queries extract different types of data crawled pages. i've been looking csquery extracing data, , seems work when have simple css-selector

h4:contains('texstring')

my problem need able evaluate complex queries following:

["h4:contains('textstring')"].parent().parent().find("div").find("span").text();

i haven't found great solution yet. csquery can above, if write in code, , since want able execute queries saved in database, need able load , execute queries dynamically. best idea make recursive function go through statement 1 dot @ time, result in 6 calls function able execute above query. seems end creating functionality present in csquery, can't figure out more elegant way solve problems.

any ideas appreciated.

there few ways this. first can use reflection , regular expressions convert c# string database expression. there lots of small projects this. option host scripting environment such iron python or jint , write expressions using 1 of those. third option use codedom , evaluate saved string converting assembly. each option has pros , cons.

the first option uses reflection can slow. can use c# natively. second option uses whole other language , requires setting scripting environment. can easier nonprogrammers develop expressions for. third option requires creating new assembly every time expression changes can't unloaded. option overall fastest in processing speed.

personally host jint keep learning curve down web folk , environment setup easy if need clr proper , csquery library access.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -