/ Published in: C#
                    
                                        
post-processing script that uses a shared script database to write extracted data to a database
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
using System;
02.using mshtml;
03.using VisualWebRipper;
04.public class Script
05.{
06. //See help for a definition of WrPostprocessArguments.
07. public static bool Postprocess(WrPostprocessArguments args)
08. {
09. try
10. {
11. //First we set the SQL we'll use to insert data into the database table.
12. //The Database connection has already been set by defining a shared script
13. //database. Visual Web Ripper will automatically open and close the
14. //database connection.
15. args.Database.SetSql
16. ("insert into properties (type,fors,title,description,area)
17. values (@type,@fors,@title,@description,@area)");
18. args.Database.PrepareSql();
19.
20. //The first table contains the start URL. We only have one start URL in
21. //this project. ChildTableRows returns all rows in the first child table
22. foreach(WrDataRow finditRow in args.DataTable.ChildTableRows)
23. {
24. //The next child table is the page navigation data table
25. foreach(WrDataRow pageRow in finditRow.ChildTableRows)
26. {
27. //The last child table is where the property data is located
28. foreach(WrDataRow propertyRow in pageRow.ChildTableRows)
29. {
30. args.Database.SetParameterTextValue("@type",
31. finditRow["type"]);
32. args.Database.SetParameterTextValue("@fors",
33. finditRow["fors"]);
34. args.Database.SetParameterTextValue("@title",
35. propertyRow["title"]);
36. args.Database.SetParameterTextValue("@description",
37. propertyRow["description"]);
38. args.Database.SetParameterTextValue("@area",
39. propertyRow["area"]);
40. args.Database.ExecuteNonQuery();
41. }
42. }
43. }
44. return true;
45. }
46. catch(Exception exp)
47. {
48. args.WriteDebug(exp.Message);
49. return false;
50. }
51. }
52.}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                